Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
810
Header Row
posted

Hello,

I have a webdatagrid in which one of my columns is select all with a checkbox in the header row and as well as in the Template row.In my checked changed event of the header checkbox , i need to check all and deselect if unchecked. How do I reference the headerrow checkbox in my checked changed event?

 

 

 

 

 

 

 

 

 

<ig:TemplateDataField Key="Select" Width="15px">

 

 

<HeaderTemplate>

 

 

<asp:CheckBox ID="cbSelectAll" runat="server" AutoPostBack="True" OnCheckedChanged="chkSelectAll_Checked"/>

 

 

</HeaderTemplate>

 

 

<ItemTemplate>

 

 

<asp:CheckBox runat="server" ID="chkRowSelection"/>

 

 

</ItemTemplate>

 

 

</ig:TemplateDataField>

I am trying something like this:

 

 

 

 

protected

 

void chkSelectAll_Checked(object sender,EventArgs e)

{

 

 

 

 

foreach (GridRecord gridRow in webDGCalendar.Rows)

{

 

 

CheckBox chk = (CheckBox)gridRow.Items[3].FindControl("chkRowSelection");

 

 

if (chk != null)

{

//if header select is checked then check all else uncheck all

chk.Checked =

true;

}

}

}

How do I reference the header row checkbox and handle the event

  • 15979
    posted

    Hello ssvan,

    Let me know if you need further assistance with your question.

  • 15979
    posted

    Hello ssvan,

    If your control is inserted in a templated column you may try to access it (the header CheckBox) from code behind like this:

    protected void <your event>(...)

    {

    WebDataGrid1.EnsureTemplates();

     

     

    TemplateDataField col = (TemplateDataField)WebDataGrid1.Columns[0];

     

     

    TemplateContainer headerTemplate = col.Header.TemplateContainer;

     

     

    CheckBox chk = (CheckBox)headerTemplate.FindControl("cbSelectAll");

    // your code here

    }

    Let me know if you have any further questions.

  • 5739
    posted

    Hi,

    See this post: http://community.infragistics.com/forums/p/31978/175907.aspx#175907

    Hopefully it works in your version.

    Ed