ASP.NET2.0下含有CheckBox的GridView删除选定记录实例(3) 19 </ItemTemplate>20 </asp:TemplateField>21 </Columns>22 <AlternatingRowStyle BackColor="Aquamarine" />23 </asp:GridView>
1 <asp:CheckBox ID="chkSelectAll" runat="server" Text="全部选中" OnCheckedChanged="chkSelectAll_CheckedChanged" AutoPostBack="True" ></asp:CheckBox>2 <asp:Button ID="btnDelete" runat="server" Text="删除" OnClick="btnDelete_Click" />
1 protected void btnDelete_Click(object sender, EventArgs e) 2 { 3 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;