-
Datagrids NavigateURL
Hey everyone,
This might sound like a stupid question but I was wondering if there was a way for me to have a HyperlinkColumn in a Datagrid and each Hyperlink went to a different page? At the moment I can only get the hyperlink to point to one site;
Code:
<asp:HyperLinkColumn Target="_blank" DataTextField="Headline" SortExpression="Headline" HeaderText="Headline" NavigateUrl="http://www.google.com">
</asp:HyperLinkColumn>
If anyone could help me with this it would be greatly appreciated, Thanks.
-
How will you get the URL for the hyperlink to use?
If it is coming from a database or whatever datasource you are using you can use a templete column like this :
Code:
<Columns>
....
<asp:TemplateColumn>
<HeaderTemplate>
HeaderText
</HeaderTemplate>
<ItemTemplate>
<asp:HyperLink ID="hyperlink1" Runat=server text="link" NavigateUrl='<%# databinder.eval(container,"dataitem.urltext") %>'></asp:HyperLink>
</itemTemplate>
</asp:TemplateColumn>
....
</columns>
Where urltext is the field in your datasource containing the url.
-
[Resolved]
Cheers mate that worked a treat. Many thanx...:)