I appologize not explaining it right the first time. I should be shot.
I understand using the function.
My thing is, I am doing everything code behind. I simply don't have an optioin use the HTML View to add do the following.
<asp:TemplateColumn>
<ItemTemplate>
<%# DataBinder.Eval(Container.DataItem, "id") %>
<%# DataBinder.Eval(Container.DataItem, "name") %>
</ItemTemplate>
</asp:TemplateColumn>
I have to actually write the whole thing in the code behind and populate it in to the datagrid. Again no access to HTML view for me to insert ASP controls. All Controls are beng generated from code behind.
I need to do the following and what I marked in red is giving me an error saying dataitem is not a member of "System.ComponentModel.Container". If I use a # sign then it says expression expected.
Dim myCol as New TemplateColumn
myCol.ItemTemplate = GetLink(DataBinder.Eval(Container.DataItem, "id"),DataBinder.Eval(Container.DataItem, "name"))
Public Function GetLink(ByVal ID As Integer, ByVal Name As String) As String
Return String.Format("mypage.aspx?ID={0}&Name={1}", ID, Name)
End Function
This gets solved, my biggest headch is over. Becasue of this problem I had to change my code to old ASP style and loop through each record, formating it into a table and then assigning it into a label. Lets not forget finding a rope next to me and hanging myself doing it in that manner rather an simply doing it with a dg.
What I understand is I have to Use ITemplate to get this working if I am going to do this programmatically...
I can't find any proper VB reference on ITemplate to get it going. Not even a simple example...
Edited by vshriniwasan