There are a series of checkboxes in the GridView. You need to select all or all of them. I found it online, but the reference code Selects all the checkboxes in the GridView, and I want all of them in a single column.
Audit and permissions must be separated.
I wrote JavaScript code and posted it for your reference.
Copy codeThe Code is as follows: function chkAll (CheckAll ){
Var items = document. getElementsByTagName ("input ");
For (var I = 0; I <items. length; I ++ ){
If (items [I]. type = "checkbox "){
For (var j = 2; j <10; j ++ ){
Var id = "ctl00_ContentPlaceHolder1_GridView1_ctl0" + j + "_ CheckBox1 ";
If (items [I]. id = id ){
Items [I]. checked = CheckAll. checked;
}
}
}
}
}
The IDS of Row j and row 5th of row 6th are used to determine the Checkbox of the same column. The range and id of the specific column j may be different. You can use alert (items [I]. id); traverse the entire items to view the corresponding id.
The front-end code is as follows:Copy codeThe Code is as follows: <asp: TemplateField HeaderText = "Review">
<HeaderTemplate>
<Asp: CheckBox ID = "chkAll" onclick = 'chkall (this) 'runat = "server"/>
Review
</HeaderTemplate>
<ItemTemplate>
<Asp: CheckBox ID = "CheckBox1" Checked = '<% # Eval ("isCheck") %> 'runat = "server"/>
</ItemTemplate>
<ItemStyle HorizontalAlign = "Center" Width = "100px"/>
</Asp: TemplateField>