Click to See Complete Forum and Search --> : HyperLink in Datagrid Datalist


bull1998
June 11th, 2002, 10:58 AM
Is there a way to make a column in DataGrid or Datalist a hyperlink? I tried <asp:HyperLink> and <a href="somelink"> but none of them worked. they always display the contents as plain text.

Thanks in advance.

Ai3xSKC
June 14th, 2002, 10:42 AM
Hi,

you have to create a &lt;asp:templatecolumn&gt;...

here's an example


&lt;asp:datagrid runat="server" id="table1"&gt;
&lt;asp:templatecolumn runat="server" id="template1"&gt;
&lt;itemtemplate&gt;
&lt;asp:hyperlink runat="server" id="link1"&gt;Click Me&lt;/asp:hyperlink&gt;
&lt;/itemtemplate&gt;
&lt;asp:templatecolumn&gt;
&lt;/asp:datagrid&gt;


you could use any asp tags in there like checkbox, linkbutton....
but remember that in order to access their properties, you have to do a FindControl on the hyperlink ID....

Steve