ASP.NET - Checkbox in telerik radgrid control

Asked By sushma on 02-Aug-11 03:28 AM
Hi All,

I have telerik radgrid contains the checkboxes in header part also, i want to check and uncheck the checkboxes. if check the header thn it should check all the checkboxes and if uncheck 1 checkbox also it should uncheck the header checkbox. how can i write the code for this in javascript, and i should call the javascrpit at server side. can any 1 send the code for this, here is the code of radgrid

 <telerik:GridTemplateColumn HeaderText="Delete" HeaderStyle-CssClass="tal la" ItemStyle-CssClass="tal la" UniqueName="chkschedulestatus">
         <HeaderTemplate>
           <asp:CheckBox runat="server" ID="chkSelectall"  Text="Delete" CssClass="chkheader"/>           
         </HeaderTemplate>
          <ItemTemplate>        
          <asp:HiddenField runat="server" ID="hdnStudentHistoryPrintID" />
          <asp:CheckBox runat="server" ID="chkSelect"/>
         </ItemTemplate>              
       </telerik:GridTemplateColumn>
Web Star replied to sushma on 02-Aug-11 03:34 AM
There are complete code with demo where you can see how it work
http://demos.telerik.com/aspnet-ajax/grid/examples/client/selecting/defaultcs.aspx
Reena Jain replied to sushma on 02-Aug-11 03:38 AM
Hi,

You can either use a GridClientSelectColumn or other wise a GridTemplateColumn with  a CheckBox in its ItemTemplate for achieving the desired scenario. Go through the following demo links for more details.
http://demos.telerik.com/ASPNET/Prometheus/Grid/Examples/Client/Selecting/DefaultCS.aspx
http://demos.telerik.com/aspnet-ajax/grid/examples/client/selecting/defaultcs.aspx
http://demos.telerik.com/ASPNET/Prometheus/Grid/Examples/Programming/SelectRowWithCheckBox/DefaultCS.aspx
http://demos.telerik.com/aspnet-ajax/grid/examples/programming/selectrowwithcheckbox/defaultcs.aspx
dipa ahuja replied to sushma on 02-Aug-11 03:39 AM
Try this:

  protected void CheckBox1_CheckedChanged(object sender, EventArgs e)
  {
    CheckBox headerChkbox = (CheckBox)sender;
    foreach (GridDataItem item in RadGrid1.Items)
    {
      CheckBox childChkbox = (CheckBox)item.FindControl("CheckBox2");
      childChkbox.Checked = headerChkbox.Checked;
    }
  }