This is a migrated thread and some comments may be shown as answers.

how to get control id in radgrid header template

3 Answers 242 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Guruvu
Top achievements
Rank 1
Guruvu asked on 19 Jan 2011, 07:53 AM
Hi,

In my radGrid i am placing CheckBox on both the ItemTemplate,HeaderTemplate.My requirement is that if i select checkbox in HeaderTemplate then all the chackBoxes in ItemTemplate  should be selected.If i de-select checkBox in HeaderTemplate then all the checkBoxes in ItemTemplate should be de-selected.

How can i achieve this requirement.Please help me...

Thanks in advance...

3 Answers, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 2
answered on 19 Jan 2011, 09:14 AM
Hello Guruvu,

The following code snippet shows how to achieve this.

ASPX:
<telerik:GridTemplateColumn>
    <HeaderTemplate>
      <asp:CheckBox ID="CheckBox1" runat="server" AutoPostBack="True"
          OnCheckedChanged="CheckBox1_CheckedChanged" />
    </HeaderTemplate>
    <ItemTemplate>
        <asp:CheckBox ID="CheckBox2" runat="server" />
    </ItemTemplate>
</telerik:GridTemplateColumn>

C#:
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;
       }
   }

Thanks,
Princy.
0
Guruvu
Top achievements
Rank 1
answered on 19 Jan 2011, 11:46 AM
Hi Princy,

Thank you very much for your quick reply.your code snippet is very much helpfull to me.

Best Regards,
D.B.Guruvu Setty.
0
Abdul
Top achievements
Rank 1
answered on 24 Apr 2017, 09:32 AM

Hi Princy

How can i achieve this in Windows Application Form?

Regards

ABDUL HAFEEL

Tags
Grid
Asked by
Guruvu
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Guruvu
Top achievements
Rank 1
Abdul
Top achievements
Rank 1
Share this question
or