<strong>aspx页</strong>: <br><div class="codetitle"> <span><a style="CURSOR: pointer" data="87994" class="copybut" id="copybut87994" onclick="doCopy('code87994')"><u>复制代码</u></a></span> 代码如下:</div> <div class="codebody" id="code87994"> <br><script src="Jquery1.7.js" type="text/javascript"></script> <br><script type="text/javascript"> <BR>$(function () { <BR>$('#Checkbox1').click(function () { <BR>if ($('#Checkbox1').is(':checked')) { <BR>$('td input').attr('checked', true); <BR>} <BR>else { $('td input').attr('checked', false); } <BR>}) <BR>$('#Checkbox2').click(function () { <BR>$('td input').each(function () { <BR>$(this).attr('checked', !$(this).attr('checked')) <BR>}) <BR>}) <BR>}) <BR></script> <br> <br> <br><form id="form1" runat="server"> <br><div> <br><input id="Checkbox1" type="checkbox">全选<input id="Checkbox2" type="checkbox">反选<button>ID="Button1" runat="server" Text="删除" onclick="Button1_Click" /> <br><gridview id="GridView1" runat="server" autogeneratecolumns="False"> <br><columns> <br><templatefield headertext="选择"> <br><itemtemplate> <br><checkbox id="CheckBox3" runat="server"></checkbox> <br></itemtemplate> <br></templatefield> <br><boundfield datafield="Id" headertext="编号"></boundfield> <br><boundfield datafield="NewsTitle" headertext="标题"></boundfield> <br><boundfield datafield="NewsContent" headertext="新闻内容"> <br><itemstyle width="200px"></itemstyle> <br></boundfield> <br><boundfield datafield="NewsCreator" headertext="创建者"></boundfield> <br><boundfield datafield="CreateTime" headertext="创建时间"></boundfield> <br></columns> <br></gridview> <br></button> </div> <br> </form> <br> </div> <br><strong>后台cs文件</strong>: <br><div class="codetitle"> <span><a style="CURSOR: pointer" data="79708" class="copybut" id="copybut79708" onclick="doCopy('code79708')"><u>复制代码</u></a></span> 代码如下:</div> <div class="codebody" id="code79708"> <br>protected void Page_Load(object sender, EventArgs e) <br>{ <br>if (!IsPostBack) <br>{ <br>load(); <br>} <br>} <br>private void load()//就实现绑定 <br>{ <br>Jquery三层实现删除功能.Model.T_News mm = new Model.T_News(); <br>Jquery三层实现删除功能.BLL.T_News bb = new BLL.T_News(); <br>string sqlwhere = "Idds = bb.GetList(sqlwhere);//获取dataset绑定 <br>this.GridView1.DataSource = ds; <br>GridView1.DataBind(); <br>} <br>protected void Button1_Click(object sender, EventArgs e) <br>{ <br>//遍历每一行 <br>foreach (GridViewRow item in GridView1.Rows)//一定要记住这里是gridviewrow不是datarow <br>{ <br>CheckBox cb = (CheckBox)item.FindControl("CheckBox3");//找到这个选中项 <br>if (cb.Checked)//选中 <br>{ <br>Jquery三层实现删除功能.BLL.T_News bb = new BLL.T_News(); <br>if (bb.DeleteList(item.Cells[1].Text))//调用bb.DeleteList(id)删除 <br>{ <br>Response.Write("删除成功"); <br>} <br>load(); <br> </div>