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
455
Get the instance of a control in the HeaderTemplate of the WebDataGrid
posted

In my WebDataGrid I have an ImageButton. I used the ImageButton to go to the parent listening of my datasource.

I have implemented the OnClick event and it works.

 

Now I want to disable the button and change the image of the button in the code behind. Is’t possible to receive the instance of the button?

 

 

My aspx code:

 

        <Columns>

            <ig:TemplateDataField Key="Image" Width="24px">

                <HeaderTemplate>

                    <asp:ImageButton ID="btnDirUp" runat="server"

                        ImageUrl="~/Images/Up.png" onclick="btnDirUp_Click" />

                </HeaderTemplate>

            </ig:TemplateDataField>

            <ig:BoundDataField DataFieldName="Name" Key="Name">

                <Header Text="Name" />

            </ig:BoundDataField>

        </Columns>

 

 

I have tried this, but it doesn't work (the code returns null values):

 

Control ctrl = wdgFiles.Columns["Image"].Header.TemplateContainer.FindControl("btnDirUp");

 

if (ctrl is ImageButton)

{

    return ((ImageButton)ctrl);

}

else

{

    return null;

}           

 How can I get the instance of this control?