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

 
GridView实现全选及删除源代码_[Asp.Net教程]

Writer: 归海一刀 Article type: Programming skills(编程技巧) Time: 2014/1/30 1:28:18 Browse times: 374 Comment times: 0

GridView实现全选及删除源代码_[Asp.Net教程]


Head photo

Go homepage
Upload pictures
Write articles

GridView实现全选及删除源代码_[Asp.Net教程] 前台代码


后台代码
protected void Button1_Click(object sender, EventArgs e) { if (Button1.Text == "全部选中") { foreach (GridViewRow row in GridView1.Rows) { CheckBox CheckBox2 = (CheckBox)row.Cells[0].FindControl("CheckBox2"); CheckBox2.Checked = true; } Button1.Text = "全部不选"; } else { foreach (GridViewRow row in GridView1.Rows) { CheckBox CheckBox2 = (CheckBox)row.Cells[0].FindControl("CheckBox2"); CheckBox2.Checked = false; } Button1.Text = "全部选中"; } } protected void Button2_Click(object sender, EventArgs e) { foreach (GridViewRow row in GridView1.Rows) { CheckBox CheckBox2 = (CheckBox)row.Cells[0].FindControl("CheckBox2"); if (CheckBox2.Checked == true) { SqlConnection conn = Fun.InitConn(); SqlCommand comm = new SqlCommand(); comm.Connection = conn; comm.CommandText = "delete from Comment where Comment_ID=’" + row.Cells[2].Text + "’ "; conn.Open(); comm.ExecuteNonQuery(); conn.Close(); } } }




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.