All articles(网络文学目录) All Pictures(图片目录) All Softwares(软件目录)

 
ASP.NET2.0下含有CheckBox的GridView删除选定记录实例_[Asp.Net教程]

Writer: delv Article type: Programming skills(编程技巧) Time: 2014/1/24 9:03:40 Browse times: 245 Comment times: 0

ASP.NET2.0下含有CheckBox的GridView删除选定记录实例_[Asp.Net教程]


Head photo

Go homepage
Upload pictures
Write articles

ASP.NET2.0下含有CheckBox的GridView删除选定记录实例_[Asp.Net教程]

前台代码 :
DataKeyNames="DB1_1,DB1_2" Height="279px" >



<%# this.GridView1.PageIndex * this.GridView1.PageSize + this.GridView1.Rows.Count + 1%>









Text="删除" >









后台代码:
protected void btnDelete_Click(object sender, EventArgs e)
{
string strDelete = "";
4 for (int i = 0; i < this.GridView1.Rows.Count; i++)
5 {
6 string Label;
7 bool isChecked = ((CheckBox)GridView1.Rows[i].FindControl("chkSelect")).Checked;
8 Label = ((Label)GridView1.Rows[i].FindControl("labXH")).Text;
9 if (isChecked)
10 {
11 strDelete = "DB1_1" + "=" + Label;
12 }
13 }
14 conn.RunSql("Delete from DB1 where " + strDelete
15 this.chkSelectAll.Checked = false;
16 GridViewBind();
17 }
18
19 protected void chkSelectAll_CheckedChanged(object sender, EventArgs e)
20 {
21 //遍历GridView行获取CheckBox属性
22 for (int i = 0; i < this.GridView1.Rows.Count; i++)
23 {
24 ((CheckBox)GridView1.Rows[i].FindControl("chkSelect")).Checked = this.chkSelectAll.Checked;
25 }
26 }

来源:网络





There are 0 records,
Comment:
Must be registered users to comment(必须是注册用户才能发表评论)

Disclaimer Privacy Policy About us Site Map
Copyright ©2011-
uuhomepage.com, Inc. All rights reserved.