双击UpdatePanel中的Button怎么没有
protected void Button_Click(object sender, EventArgs e)
{
}
产生??需要手工添加的吗??主要是想让 UpdatePanel 刷新时就执行如下的一段代码,但 UpdatePane2 刷新时不要执行。if (GridView1.Rows.Count != 0)
{
string my1 = GridView1.Rows[0].Cells[1].Text.ToString();
string my2 = GridView1.Rows[0].Cells[2].Text.ToString();
string my3 = GridView1.Rows[0].Cells[3].Text.ToString();
string my4 = GridView1.Rows[0].Cells[4].Text.ToString();
String myConnectionString = "Initial Catalog=mysqldatabase;Data Source=localhost;Integrated Security=SSPI;";
System.Data.SqlClient.SqlConnection myConnection = new System.Data.SqlClient.SqlConnection(myConnectionString);
string myInsertQuery = "INSERT INTO nianji (banji, xingming,zhongfen,huaxue) Values('" + my1 + "', '" + my2 + "','" + my3 + "','" + my4 + "')";
System.Data.SqlClient.SqlCommand myCommand = new System.Data.SqlClient.SqlCommand(myInsertQuery);
myCommand.Connection = myConnection;
myConnection.Open();
myCommand.ExecuteNonQuery();
myCommand.Connection.Close();
GridView2.DataBind();
正确的做法是什么?谢谢!!!
protected void Button_Click(object sender, EventArgs e)
{
}
产生??需要手工添加的吗??主要是想让 UpdatePanel 刷新时就执行如下的一段代码,但 UpdatePane2 刷新时不要执行。if (GridView1.Rows.Count != 0)
{
string my1 = GridView1.Rows[0].Cells[1].Text.ToString();
string my2 = GridView1.Rows[0].Cells[2].Text.ToString();
string my3 = GridView1.Rows[0].Cells[3].Text.ToString();
string my4 = GridView1.Rows[0].Cells[4].Text.ToString();
String myConnectionString = "Initial Catalog=mysqldatabase;Data Source=localhost;Integrated Security=SSPI;";
System.Data.SqlClient.SqlConnection myConnection = new System.Data.SqlClient.SqlConnection(myConnectionString);
string myInsertQuery = "INSERT INTO nianji (banji, xingming,zhongfen,huaxue) Values('" + my1 + "', '" + my2 + "','" + my3 + "','" + my4 + "')";
System.Data.SqlClient.SqlCommand myCommand = new System.Data.SqlClient.SqlCommand(myInsertQuery);
myCommand.Connection = myConnection;
myConnection.Open();
myCommand.ExecuteNonQuery();
myCommand.Connection.Close();
GridView2.DataBind();
正确的做法是什么?谢谢!!!
protected void Button_Click(object sender, EventArgs e)
{
}
产生??需要手工添加的吗??
=====================================
不需要手工添加,如果出现这样的问题,请检查你的aspx文件的页面指令
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="XXX.aspx.cs" Inherits="后置代码类名" %>aspx.cs中
public partial class 类名aspx.designer.cs
public partial class 类名看看这三个地方命名空间和类名是否完全一致
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %>Default2.aspx.cs中
public partial class Default2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{ }没有找到 aspx.designer.cs 。双击UpdatePanel中的Button,就会直接跳到 Default2.aspx.cs 中的protected void Page_Load()里面。
要不是选择的Page Load的话 你就把那个按钮删除 重新添加一个按钮试下