会员
周边
众包
新闻
博问
闪存
所有博客
当前博客
我的博客
我的园子
账号设置
简洁模式
...
退出登录
注册
登录
a121984376
公告
日历
导航
博客园
首页
新随笔
新文章
联系
订阅
管理
手动写GridView的RowEditing RowCancelingEdit RowUpdating RowDeleting 事件 和 删除 出现提示
先定一个绑定的方法
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();
}
protected
void
GridViewUser_RowUpdating(
object
sender, GridViewUpdateEventArgs 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('你确认要删吗?')
"
);
}
}
}
posted on
2008-07-18 11:42
冰之玄岩,小小Programmer
阅读(
3851
) 评论(
4
)
编辑
收藏
举报
会员力量,点亮园子希望
刷新页面
返回顶部
Copyright © 2024 冰之玄岩,小小Programmer
Powered by .NET 8.0 on Kubernetes