1. Set columns in the GridView
Copy codeThe Code is as follows:
<Asp: TemplateField HeaderStyle-CssClass = "check" ItemStyle-CssClass = "check">
<HeaderTemplate>
<Input type = "checkbox" onclick = "selectAll (this)"/>
Select All
</HeaderTemplate>
<ItemTemplate>
<Input name = "chkIDCardNum" type = "checkbox"
Value = "<% # Eval (" PID ") % >$ <% # Eval (" IdentityCard ") % >$ <% # Eval (" PName ") %>"
<% # "1" = Eval ("IsCouldDelete"). ToString ()? "Disabled = 'Disabled '": "" %>/>
</ItemTemplate>
</Asp: TemplateField>
<Asp: TemplateField Visible = "true" HeaderText = "delete">
<ItemTemplate>
<Asp: LinkButton id = "lbtnDelete" CommandName = "lbtnDelete" runat = "server" Text = "delete file"
CommandArgument = '<% # Eval ("PID") + "$" + Eval ("IdentityCard") %>'
OnClientClick = "return confirm ('Are you sure you want to delete it? ');"
Visible = '<% # Eval ("Termination"). ToString () = "1 "? False: true %> '/>
</ItemTemplate>
</Asp: TemplateField>
2. Select All Js Processing
Copy codeThe Code is as follows:
Function selectAll (myself ){
Var oState = myself. checked;
Var checkboxes = document. getElementsByName ("chkIDCardNum"); // obtain the input Group
For (var I = 0; I <checkboxes. length; I ++ ){
If (checkboxes [I]. disabled ){
} Else {
Checkboxes [I]. checked = oState; // select a value
}
}
}
3. Obtain the selected value in the background
Copy codeThe Code is as follows:
Var selectedIds = Request. Params ["chkIDCardNum"]. Split (',');
If (selectedIds. Length = 0)
Return;
// Int [] msgIds = Array. ConvertAll <string, int> (selectedIds, s => int. Parse (s ));
Int [] ids = selectedIds. Select (t => int. Parse (t. Split ('$') [0]). ToArray ();
String [] cards = selectedIds. Select (t => t. Split ('$') [1]). ToArray ();