I am using the webdatagrid Version=11.1.20111.2075.
We have developed a wrapper that automatically generates the columns and all our standard settings in code behind which is working fine.
We now have a requirement for one of those columns to be a hyperlink, looking through the various posts the recommended way to achieve this in a webdatagrid is through a templatedatafield.
I have found the following example from a previous post (sorry did not save link)
<ig:WebDataGrid ID="wgLinks" runat="server" Width="80px" AutoGenerateColumns="False" DataKeyFields="Web_Link" StyleSetName="WestonBlue" AltItemCssClass="WestonAltBlueItem" ShowHeader="False"> <Columns> <ig:TemplateDataField Key="Web_Link" Width="100%"> <ItemTemplate> <asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl='<%# Eval("Web_Link") %>' Text='<%# Eval("HTML_Desc") %>' > </asp:HyperLink> </ItemTemplate> </ig:TemplateDataField> </Columns></ig:WebDataGrid>
Which works fine for us, but I would like to add support for this in our wrapper and we are struggling and adding a templatedatafield in vb.bnet code behind? or is there a better way to acheive hyperlinks in code behind.
Any help would be appreciated and any links to any articles or help on the uses of templatedatafield would also be helpful.
thanksKevin
Hi,
I have a dynamically created TemplateDataField of ImageButton controls in my WHDG (with your example).
I have registered a Click event to that ImageButton, however even though the ImageButton appears in the Grid, it is not responding to my Click event method. See my code below.
What is wrong?
//Class code for my image button Template (as in example)
class eclms_ItemTemplate_ImgBtn : ITemplate { String strImageUrl = ""; ImageClickEventHandler imgClickHandler;
public eclms_ItemTemplate_ImgBtn(String strImageUrl, ImageClickEventHandler imgClickHandler) { this.strImageUrl = strImageUrl; this.imgClickHandler = imgClickHandler; }
public void InstantiateIn(Control container) { ImageButton imgbtnControl = new ImageButton(); imgbtnControl.ImageUrl = this.strImageUrl; imgbtnControl.Click += this.imgClickHandler;
container.Controls.Add(imgbtnControl); } }
//And also the dynamically instantiating code on runtime
Hello Kevin,
please check this out: http://help.infragistics.com/NetAdvantage/ASPNET/2011.2/CLR4.0/?page=WebDataGrid_Using_Item_Template.html
Let me know if you need further assistance