CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    May 2002
    Posts
    12

    HyperLink in Datagrid Datalist

    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.

  2. #2
    Join Date
    Oct 2001
    Posts
    31
    Hi,

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

    here's an example

    Code:
    &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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured