can i change a HyperlinkURL in a Template field in a GridView via

G

Guest

I have a gridview inside a content placeholder that has the first column as a
hyperlink. I changed it from a Hyperlinkfield to a Template field so I could
name the hyperlink control. I can't figure out how to reference it so I can
change the URL depending on which Stored procedure I bind to it during form
load.

Is there a way to change it URL via VB. This is in a content form within a
master page if that makes any difference.

Thank you in advance for your help.

J
 
G

Guest

if you are trying to change the URL based on the data then you might find it
easier to add to your dataset a field indicating which URL to be used. You
would then databind it to the HyperLinkField like this:

<asp:hyperlinkfield datatextfield="UnitPrice" datatextformatstring="{0:c}"
datanavigateurlfields="URL, ProductID"
datanavigateurlformatstring="{0}?ProductID={1}" headertext="Price"
target="_blank" />

in the above syntax the URL (.e.g http://some.website.com) is saved in a
field named URL and the ProductID is a parameter to be passed in the
querystring to that URL. Notice how you can use the
datanavigateurlformatstring to compose the URL out of more than one field.

On the other hand if you wish to use a HyperLink server control within an
ItemTemplate then you can bind the data using the Eval statement:
<asp:HyperLink ID=â€hlLink1†runat=â€server†NavigateUrl=’<%# Eval(“URLâ€) &
“?ProductID†& Eval(“ProductIDâ€) %>’ Text =’<%# Eval(“UnitPriceâ€)%>’/>
 

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

No members online now.

Forum statistics

Threads
474,444
Messages
2,571,709
Members
48,796
Latest member
Greg L.
Top