asp.net 编辑gridview的小例子
编程学习 2021-07-04 22:40www.dzhlxh.cn编程入门
gridview的编辑方法的小例子,一段代码,供大家学习参考
编辑例子,完整代码如下。
protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
{
GridView1.EditIndex = e.NewEditIndex;
BingGrid();
}
protected void GridView1_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
{
GridView1.EditIndex = -1;
BingGrid();
}
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
try
{
GridViewRow row = GridView1.Rows[e.RowIndex];
string TXB_FORUMNAME = ((TextBox)row.FindControl("TXB_FORUMNAME")).Text.Trim().ToString();
int TXB_ROOTFORUMID = Convert.ToInt16(((TextBox)row.FindControl("TXB_ROOTFORUMID")).Text.Trim());
int TXB_ISDISPLAY = Convert.ToInt16(((TextBox)row.FindControl("TXB_ISDISPLAY")).Text.Trim());
string TXB_MASTER = ((TextBox)row.FindControl("TXB_MASTER")).Text.ToString();
int TXB_ISLOCK = Convert.ToInt16(((TextBox)row.FindControl("TXB_ISLOCK")).Text.Trim());
int LB_FORUMID=Convert.ToInt16(((Label)row.FindControl("Label6")).Text);
ForumBLL.Forum_Update_Name(TXB_FORUMNAME, TXB_ISDISPLAY, TXB_ROOTFORUMID, TXB_MASTER, TXB_ISLOCK, LB_FORUMID);
}
catch (Exception ex)
{
Response.Write(ex);
}
GridView1.EditIndex = -1;
BingGrid();
}
GridView直接编辑,删除经典例子
代码如下:
protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
{
GridView1.EditIndex = e.NewEditIndex;
BingGrid();
}
protected void GridView1_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
{
GridView1.EditIndex = -1;
BingGrid();
}
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
try
{
GridViewRow row = GridView1.Rows[e.RowIndex];
string TXB_FORUMNAME = ((TextBox)row.FindControl("TXB_FORUMNAME")).Text.Trim().ToString();
int TXB_ROOTFORUMID = Convert.ToInt16(((TextBox)row.FindControl("TXB_ROOTFORUMID")).Text.Trim());
int TXB_ISDISPLAY = Convert.ToInt16(((TextBox)row.FindControl("TXB_ISDISPLAY")).Text.Trim());
string TXB_MASTER = ((TextBox)row.FindControl("TXB_MASTER")).Text.ToString();
int TXB_ISLOCK = Convert.ToInt16(((TextBox)row.FindControl("TXB_ISLOCK")).Text.Trim());
int LB_FORUMID=Convert.ToInt16(((Label)row.FindControl("Label6")).Text);
ForumBLL.Forum_Update_Name(TXB_FORUMNAME, TXB_ISDISPLAY, TXB_ROOTFORUMID, TXB_MASTER, TXB_ISLOCK, LB_FORUMID);
}
catch (Exception ex)
{
Response.Write(ex);
}
GridView1.EditIndex = -1;
BingGrid();
}
GridView直接编辑,删除经典例子