会员
周边
众包
新闻
博问
闪存
所有博客
当前博客
我的博客
我的园子
账号设置
简洁模式
...
退出登录
注册
登录
しovのんeТs
しovのんeТs → 多一份坚持,多一份自信,便能做自己想做的人,做好自己想做的事!
新随笔
管理
GridView动态绑定数据、编辑、修改、删除及分页功能
GridView动态绑定数据、编辑、修改、删除及分页功能
protected
void
Page_Load(
object
sender, EventArgs e)
{
if
(
!
Page.IsPostBack)
{
deptDataBind();
}
}
//
数据绑定到控件
protected
void
deptDataBind()
{
//
这是一个动态绑定到控件的函数
}
//
点击编辑进入到编辑状态
public
void
dept_Edit(Object sender, GridViewEditEventArgs e)
{
dept.EditIndex
=
(
int
)e.NewEditIndex;
deptDataBind();
}
//
删除数据控件上一行
public
void
dept_Delete(Object sender, GridViewDeleteEventArgs e)
{
Dept _dept
=
new
Dept();
int
Dept_ID
=
Int32.Parse(((Label)dept.Rows[e.RowIndex].Cells[
0
].Controls[
0
]).Text);
if
(_dept.Del(Dept_ID)
==
1
)
{
Response.Write(
"
<script>alert('删除成功!');</script>
"
);
}
else
{
Response.Write(
"
<script>alert('删除失败!');</script>
"
);
}
deptDataBind();
}
//
取消数据控件上编辑
public
void
dept_Cancel(Object sender, GridViewCancelEditEventArgs e)
{
dept.EditIndex
=
-
1
;
deptDataBind();
}
//
把数据控件上的数据更新到数据据库中
public
void
dept_Update(Object sender, GridViewUpdateEventArgs e)
{
dept.FooterRow.Enabled
=
false
;
Dept _dept
=
new
Dept();
int
dept_ID
=
Int32.Parse(((Label)dept.Rows[e.RowIndex].Cells[
0
].Controls[
0
]).Text);
string
dept_Name
=
((TextBox)dept.Rows[e.RowIndex].Cells[
1
].Controls[
0
]).Text;
//
……进行相关的更新打操作
deptDataBind();
}
//
进行分页显示
public
void
dept_PageIndexChanging(
object
sender, GridViewPageEventArgs e)
{
dept.PageIndex
=
e.NewPageIndex;
deptDataBind();
}
posted @
2007-01-29 05:54
しovのんeТs
阅读(
2794
) 评论(
1
)
编辑
收藏
举报
会员力量,点亮园子希望
刷新页面
返回顶部