Home > ASP.Net, Javascript > Select All CheckBoxes in Repeater Control

Select All CheckBoxes in Repeater Control

Hi all,

try this example to select all checkbox in Repeater control when i check a CheckBox in header

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
 <script type="text/javascript">
 function checkAll(cb) {
 var ctrls = document.getElementsByTagName('input');
 for (var i = 0; i < ctrls.length; i++) {
 var cbox = ctrls[i];
 if (cbox.type == "checkbox") {
 cbox.checked = cb.checked;
 <form id="form1" runat="server">
 <asp:Repeater ID="Repeater1" runat="server" DataSourceID="SqlDataSource1">
 <table style="width: 60%; margin: 2px;">
 <tr style="background-color: Gray;">
 <asp:CheckBox ID="cbCheckAll" runat="server" Text="Select All" OnClick="checkAll(this)" />
 Category Name
 <asp:CheckBox ID="chk" runat="server" />
 <asp:Label ID="lbl_Name" runat="server" Text='<%#Eval("CategoryName")%>'></asp:Label>
 <asp:Label ID="lbl_Description" runat="server" Text='<%#Eval("Description")%>'></asp:Label>
 <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"
 SelectCommand="SELECT [CategoryID], [CategoryName], [Description] FROM [Categories]">

Hope this helps

Good Luck

Categories: ASP.Net, Javascript
  1. anonymous
    June 27, 2012 at 11:21 am

    excellent thankyou

  2. July 3, 2013 at 9:16 am

    thanksss a tonnn

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: