Code:
1. <script type="text/javascript">
2. function
3. {
4. var checks = document.getElementById('<%=GridView1.ClientID %>');
5. if(sender.checked)
6. {
7. alert(checks.rows.length.toString());
8. for(var
9. {
10. var ch = checks.rows[i].cells[0].getElementsByTagName("input")[0];
11. true;
12. }
13. }
14. else
15. {
16. for(var
17. {
18. "input")[0].checked = false;
19. }
20. }
21. }
22. </script>
GridView:
Code:
1. <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="True"
2. DataKeyNames="sid" DataSourceID="SqlDataSource1">
3. <Columns>
4. <asp:TemplateField>
5. <HeaderTemplate>
6. <input ID="Checkbox1" runat="server" onclick="change(this);" type="checkbox" /></HeaderTemplate>
7. <ItemTemplate>
8. <asp:CheckBox ID="CheckBox2" runat="server" AutoPostBack="True"
9. />
10. </ItemTemplate>
11. </asp:TemplateField>
12. </Columns>
13. </asp:GridView>
标签:rows,checked,全选,GridView,全不选,var,input,checks From: https://blog.51cto.com/u_14365218/6019379