Using Field Value as Hyperlink Name

  • Thread starter Thread starter Wayne Wengert
  • Start date Start date
W

Wayne Wengert

I want to use the contents of one field to be the text the user clicks on
for a hyperlink in a datagrid. I am trying the following code but it does
not work. What is the correct syntax for this? The field "InfoURL" contains
the hyperlink and the field "City" is a string field containing the text I
want the user to be able to clock on.

<columns>
<asp:BoundColumn HeaderText="Start Date" DataField="StartDate"
DataFormatString="{0:d}" />
<asp:BoundColumn HeaderText="Max<br>Perc<br>Units" DataField="MaxLoc" />
<asp:HyperlinkColumn
HeaderText="Info URL"
DataNavigateURLField="InfoURL"
Text=<%# Container.DataItem("City") %>.ToString />
</columns>

Wayne
 
try using a template column like this

<asp:TemplateColumn>
<ItemTemplate>
<P align="center">
<asp:HyperLink NavigateUrl='<%#
"CA_ShowProductStock.aspx?ProductID=" +
DataBinder.Eval(Container.DataItem,"ProductID") + "&ProductColorID=" +
DataBinder.Eval(Container.DataItem,"ProductColorID") %>' runat="server"
ID="Hyperlink2">Size<br>&<br> Stock</asp:HyperLink>
</P>
</ItemTemplate>
</asp:TemplateColumn>
 
Back
Top