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">
<ig:BoundDataField DataFieldName="NAME" Key="NAME" CssClass="name">
<Header Text="User Name" CssClass="name" Tooltip="User Name" />
<ig:TemplateDataField Key="Edit" CssClass="edit" Width="6%">
<Header CssClass="edit" />
<asp:LinkButton ID="btnEdit" runat="server" Text="Edit" CausesValidation="false"
</ig:WebDataGrid>.CS Pageprotected void edit_Click(object sender, EventArgs e)
LinkButton edit = sender as LinkButton;
//Do Something }
catch (Exception ex)
}Is it needed to register the event anywhere in code?Please help.
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 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.
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.
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);
Please reply ASAP, Thanks.
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!