asp.net 编辑gridview的小例子
作者:
gridview的编辑方法的小例子,一段代码,供大家学习参考
编辑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直接编辑,删除经典例子下载
您可能感兴趣的文章:
- asp.net下gridview 批量删除的实现方法
- Asp.Net+XML操作基类(修改,删除,新增,创建)
- asp.net GridView 删除时弹出确认对话框(包括内容提示)
- asp.net中gridview的查询、分页、编辑更新、删除的实例代码
- Asp.net的GridView控件实现单元格可编辑方便用户使用
- ASP.NET MVC4入门教程(六):验证编辑方法和编辑视图
- 在ASP.NET 2.0中操作数据之十六:概述插入、更新和删除数据
- 在ASP.NET 2.0中操作数据之十七:研究插入、更新和删除的关联事件
- 在ASP.NET 2.0中操作数据之十九:给编辑和新增界面增加验证控件
- 在ASP.NET 2.0中操作数据之二十二:为删除数据添加客户端确认
- 在ASP.NET 2.0中操作数据之三十六:在DataList里编辑和删除数据概述