C#中Gridview自带的"编辑"按钮
来源:百度知道 编辑:UC知道 时间:2024/06/28 03:36:04
点完编辑按钮能够进入编辑状态,原来的编辑按钮也会变成"更新"和"取消"
但是点更新和取消后都没有反应,不知是何原因?
附上部分代码
前台:
OnRowEditing="GridView1_RowEditing" OnRowUpdating="GridView1_RowUpdating"
OnRowCancelingEdit="GridView1_RowCancelingEdit"
<asp:CommandField HeaderText="编辑" ShowEditButton="True"/>
后台:
protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
{
Label3.Text = "Edit";
GridView1.EditIndex = e.NewEditIndex;
bind();
}
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
Label3.Text = "update";
}
protected void GridView1_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
{
Label3.Text = "Cancel";
GridView1.EditIndex = -1;
bind();
}
但是点更新和取消后都没有反应,不知是何原因?
附上部分代码
前台:
OnRowEditing="GridView1_RowEditing" OnRowUpdating="GridView1_RowUpdating"
OnRowCancelingEdit="GridView1_RowCancelingEdit"
<asp:CommandField HeaderText="编辑" ShowEditButton="True"/>
后台:
protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
{
Label3.Text = "Edit";
GridView1.EditIndex = e.NewEditIndex;
bind();
}
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
Label3.Text = "update";
}
protected void GridView1_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
{
Label3.Text = "Cancel";
GridView1.EditIndex = -1;
bind();
}
应该不是代码的问题吧,这个是自动生成
如果你要自己写点击按钮的功能,那么不能用gridview自带的编辑/更新/取消按钮,这三个按钮上面不要有OnClick
应该是 bind();有问题吧
看着没什么问题啊!
bind();
这个代码会不会有问题呢