This works..but if i have beaviors enabled then if i sort it gives me an object reference error. I am adding the above said code to InitializeRow .
Is there a way to make behaviors work on child grid when you have hyperlinks in child grid?
Hi dev_here,
It should look something similar to:
link.Text = ((DataRowView)(((TemplateContainer)container).DataItem)).Row["Name"].ToString();
Let me know if this works for you.
Ok that works but how do i get the text to show up in the column?
For example the code in .aspx
<asp:HyperLink ID="link" runat="server" ForeColor="blue" Text='<% #DataBinder.Eval(Container,"DataItem.Name") %>'>
</asp:HyperLink>
How can i change it to code behind:
link.Text=DataBinder.Eval(Container,"DataItem.Name")?????
You could create a TemplatedDataField in the child grid like in the RowIslandPopulating event handler like this:
TemplateDataField col = new TemplateDataField();col.ItemTemplate = new ActionChildItemTemplate();col.Key = "TemplatedColumn";
And here is sample ActionChildItemTemplate class:
public class ActionChildItemTemplate : ITemplate{
#region ITemplate Member
public void InstantiateIn(Control container) { HyperLink link = new HyperLink(); link.ID = "link"; link.ForeColor = Color.Blue; container.Controls.Add(link); }
#endregion
}
Hope this helps.
What if i need this hyperlink column to be in a child grid using manual on demand?
Can you give me an example of how I would then define the column in child grid?