手动写GridView的RowEditing RowCancelingEdit RowUpdating RowDeleting 事件 和 删除 出现提示
2008-04-01 11:51
387 查看
先定一个绑定的方法
void Bind()
...{
this.GridViewUser.DataSource = new BILL.OperateUser().SelectOneUserSqlComd();
this.GridViewUser.DataBind();
}
protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
...{
//索引编辑时
this.GridViewUser.EditIndex = e.NewEditIndex;
Bind();
}
protected void GridView1_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
...{
//编辑结束时
this.GridViewUser.EditIndex = -1;
Bind();
}
GridView的AutoGenerateDeleteButton="True" AutoGenerateEditButton="True"
//删除出现提示
protected void GridViewUser_RowDataBound(object sender, GridViewRowEventArgs e)
...{
//如果是绑定数据行
if (e.Row.RowType == DataControlRowType.DataRow)
...{
if (e.Row.RowState == DataControlRowState.Normal || e.Row.RowState == DataControlRowState.Alternate)
...{ //找到生成“删除”所在单元格
LinkButton lb = (LinkButton)e.Row.Cells[0].Controls[2];
lb.Attributes.Add("onclick", "javascript:return confirm('你确认要删吗?')");
}
}
}
void Bind()
...{
this.GridViewUser.DataSource = new BILL.OperateUser().SelectOneUserSqlComd();
this.GridViewUser.DataBind();
}
protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
...{
//索引编辑时
this.GridViewUser.EditIndex = e.NewEditIndex;
Bind();
}
protected void GridView1_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
...{
//编辑结束时
this.GridViewUser.EditIndex = -1;
Bind();
}
GridView的AutoGenerateDeleteButton="True" AutoGenerateEditButton="True"
//删除出现提示
protected void GridViewUser_RowDataBound(object sender, GridViewRowEventArgs e)
...{
//如果是绑定数据行
if (e.Row.RowType == DataControlRowType.DataRow)
...{
if (e.Row.RowState == DataControlRowState.Normal || e.Row.RowState == DataControlRowState.Alternate)
...{ //找到生成“删除”所在单元格
LinkButton lb = (LinkButton)e.Row.Cells[0].Controls[2];
lb.Attributes.Add("onclick", "javascript:return confirm('你确认要删吗?')");
}
}
}
相关文章推荐
- MATLAB 2008
- 3月第4周回顾:微软OOXML被通过为国际标准 黑客大赛开幕
- Engine中IFeatureClass.Search(filter, Recycling)方法中Recycling-转载
- Delegate和泛型结合运用(一)
- 数据仓库与事务型数据库的区别
- [转]vsftp配置大全
- 数据结构与算法系列---顺序表
- CheckBoxList 的数据绑定及数据获取
- PPP 和PPPOE协议介绍
- 生命的意義
- Win32平台结构化异常与Win32平台多线程产生之间的关系
- Visual Studio菜单下不见“导出模板”菜单项
- cmd.exe - Windows Command Line Reference
- 《你必须知道的.NET》图书专题上线
- 今天决定看书考网络工程师!!
- C#利用自身函数启动外部程序
- ASP.NET生成静态页面实现方法
- 《Web设计艺术精髓》
- (视频)玩转Membership视频之五:底层三剑客:Membership、MembershipUser、Roles
- 初学eclipse,记录一些有关eclipse IDE使用的东东