asp.net 编辑gridview的小例子
程序员文章站
2024-03-01 20:46:28
编辑例子,完整代码如下。复制代码 代码如下:protected void gridview1_rowediting(object sender, gridviewedite...
编辑例子,完整代码如下。
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直接编辑,删除经典例子下载