GridView中全选和反选
1. 带回发
GridView中贴: <asp:TemplateField FooterStyle-HorizontalAlign="Center"> <ItemTemplate> <asp:CheckBox ID="chk_ItemAll" runat="server" /> </ItemTemplate> <HeaderTemplate> <asp:CheckBox ID="chk_HeadAll" runat="server" OnCheckedChanged="SelectAll" AutoPostBack="true"/> </HeaderTemplate> </asp:TemplateField> 后台贴: protected void SelectAll(object sender, EventArgs e) { bool isChecked = ((CheckBox)(grd_SMSNumberSet.HeaderRow.Cells[0].FindControl("chk_HeadAll"))).Checked; foreach (GridViewRow gvRow in grd_SMSNumberSet.Rows) { ((CheckBox)(gvRow.Cells[0].FindControl("chk_ItemAll"))).Checked = isChecked; } }