This article is a mirror article of machine translation, please click here to jump to the original article.

View: 20507|Reply: 2

[ASP.NET] In the asp.net, CheckBox selects 2 methods for all CheckBoxes

[Copy link]
Posted on 7/29/2015 3:01:33 PM | | | |


Click the CheckBox box at the top to select all the following CheckBoxes, in Method 2;

The first type:
Background Code:
  1. protected void ckball_CheckedChanged(object sender, EventArgs e)
  2.         {
  3.             CheckBox ck=sender as CheckBox;
  4.             bool ci=ck.Checked;
  5.             for (int i = 0; i < gvusers.Rows.Count; i++)
  6.             {
  7.                 CheckBox o = gvusers.Rows[i].Cells[1].FindControl("ckxz") as CheckBox;
  8.                 o.Checked = ci;
  9.             }
  10.         }
Copy code
Front Desk Code:
  1. <asp:TemplateField>
  2.                                 <HeaderTemplate>
  3.                                     <asp:CheckBox ID="ckball" runat="server"
  4.                                         oncheckedchanged="ckball_CheckedChanged" AutoPostBack="True" />
  5.                                 </HeaderTemplate>
  6.                                 <ItemTemplate>
  7.                                     <asp:CheckBox ID="ckxz" runat="server" />
  8.                                 </ItemTemplate>
  9.                             </asp:TemplateField>
Copy code






Previous:Insider Causes and Solutions for "Adobe Flash Player Blocked Due to Expiration"
Next:Solved no left connection in linq
 Landlord| Posted on 7/29/2015 3:27:08 PM |
Second method:
  1. <input id="ckall" type="checkbox" onclick="selectall(this);" />
Copy code

  1. <scrip去掉t src="scrip去掉ts/jquery-1.4.1.min.js" type="text/javascrip去掉t"></scrip去掉t>
  2. <scrip去掉t type="text/javascrip去掉t">
  3.     function selectall(ck) {
  4.         var bol = ck.checked;
  5.         $("#MainContent_gvusers td :checkbox").each(function () {
  6.             this.checked = bol;
  7.         });
  8.     }
  9. </scrip去掉t>
Copy code


Posted on 7/8/2017 4:03:24 PM |
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com