Skip to content

Infragistics Community Forum / Web / Ultimate UI for ASP.NET Web Forms / Link Button event not fired when used in TemplateDataField of WebDataGrid

Link Button event not fired when used in TemplateDataField of WebDataGrid

New Discussion
harshgandhi18
harshgandhi18 asked on Dec 29, 2013 4:34 AM

Hi There,

I am using a WebDataGrid in which there is a TemplateDataField.
I have added a Link Button there and added “OnClick” event of a button in Code Behind (C#).
The event is not triggered at any point of time.
I have also put a break point to troubleshoot but the break point is not getting hit anyhow.

I have added sample code here.

 

.ASPX Page

<ig:WebDataGrid ID="Users" runat="server" Width="100%" AutoGenerateColumns="false">
<Columns>
  <ig:BoundDataField DataFieldName="NAME" Key="NAME" CssClass="name">
    <Header Text="User Name" CssClass="name" Tooltip="User Name" />
  </ig:BoundDataField>
<ig:TemplateDataField Key="Edit" CssClass="edit" Width="6%">
  <Header CssClass="edit" />
  <ItemTemplate>
      <asp:LinkButton ID="btnEdit" runat="server" Text="Edit" CausesValidation="false"
      OnClick="edit_Click" CommandName="edit_Click"/>
  </ItemTemplate>
 </ig:TemplateDataField>
 </Columns>
 </ig:WebDataGrid>

 


.CS Page

protected void edit_Click(object sender, EventArgs e) {
  LinkButton edit = sender as LinkButton;
  try   {
    //Do Something
  }   catch (Exception ex)  {
    throw;
  }
}

 

Is it needed to register the event anywhere in code?

Please help.

Sign In to post a reply

Replies

  • 0
    [Infragistics] Radoslav Minchev
    [Infragistics] Radoslav Minchev answered on Aug 24, 2011 9:19 AM

    Hi,

    I've tested your code with 11.1 Version and it seems to work on my side. I am able to hit the edit_Click  handler on the server when i press a link button. Can you test this with the 11.1 Version and see if it works.

    Thanks,

    • 0
      harshgandhi18
      harshgandhi18 answered on Aug 24, 2011 12:15 PM

      Hi,

      Thanks for your quick reply.

      I am using 11.1 version only but the code does not seem to be working anyhow.

      I was asking whether do I need to register this event anywhere else in the code or not?

      I have placed the WebDataGrid in a Content Page under an UpdatePanel content template.

      Can you please upload the sample that you have created? It would be helpful for me I guess.

      Thanks in advance.

       

       

      • 0
        [Infragistics] Radoslav Minchev
        [Infragistics] Radoslav Minchev answered on Aug 24, 2011 2:13 PM

        Hi it's not needed to register the event anywhere else as long as you registered it in the markup. Attached is may basic sample, please note it consists of only one page and web.config, the ig_res folder was removed to make the sample lighter.  You can unzip the folder then open it as a website in Visual Studio and get into design mode, this action will generate the ig_res folder for you.

        Run the sample in debug mode and press any link form link column and you should get a break point hit on the server inside edit_Click event handler.

         

      • 0
        Chinho
        Chinho answered on Dec 28, 2013 5:03 AM

        Hi,

        Based on your example, you have created your LinkButton column in HTML, thats why it works. What if we want to create the TemplateDataField LinkButton column in runtime??

        How shall we approach registering the event in the InstantiateIn() of the ITemplate class, because the convention

        lnkButton.Click += new EvtHandler(xxxx);

        doesnt work.

        Please reply ASAP, Thanks.

        cno

      • 0
        Chinho
        Chinho answered on Dec 29, 2013 4:34 AM

        Hi,

        I have GOT it. Basically to solve this issue of events not triggering, I move my even registering from Page_Load to Page_Init.

        It seems my registering of event handler was too late. When I move it to Page_Init, it works!

        Thanks.

        cno

  • You must be logged in to reply to this topic.
Discussion created by
Favorites
Replies
Created On
Last Post
Discussion created by
harshgandhi18
Favorites
0
Replies
5
Created On
Dec 29, 2013
Last Post
12 years, 3 months ago

Suggested Discussions

Created by

Created on

Dec 29, 2013 4:34 AM

Last activity on

Feb 24, 2026 7:58 AM