Select the CheckBox column of the GridView and pass multiple parameters in three steps.

Source: Internet
Author: User

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 ();

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.