Using Field Value as Hyperlink Name

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
 
H

Hermit Dave

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>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,776
Messages
2,569,603
Members
45,189
Latest member
CryptoTaxSoftware

Latest Threads

Top