Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to set DataNavigateUrlFormatString from a function

Status
Not open for further replies.

cmn2

Programmer
Mar 6, 2003
73
0
0
US
Could someone please help me understand what I am doing wrong. I have tried endlessly trying to get this to work.
All I get is errors.
Thank you.

Here is what I want to do:

I have a gridview with a hyperlink field. I want to set the DataNavigateUrlFormatString with a function call while passing it a parameter thus building a proper hyperlink.

Here is the hyperlink:

<asp:HyperLinkField DataNavigateUrlFields="Account" DataTextField="AccountName" HeaderText="Account" DataNavigateUrlFormatString='<%# GetURL(account={0}) %>'>
</asp:HyperLinkField>

and here is my function:

Public Function GetURL(ByVal userAccount As String) As String
Dim strReturn As String = ConfigurationManager.AppSettings
("PortalProfileURL").ToString & "'" & userAccount & "'"
Return strReturn
End Function

 
What isn't working?
Why not just use the RowDataBoundEvent, and use findcontrol() to find the hyperlink, and then set the property?
 
Thanks for the quick reply. Here is a little more background.

I am getting a build error:
Databinding expressions are only supported on object that have a DataBinding event. HyperLinkField does not have a DataBinding event.

When I hard-code the DataNavigateUrlFormatString it works fine.
<asp:HyperLinkField DataNavigateUrlFields="Account" DataTextField="AccountName" HeaderText="Account" DataNavigateUrlFormatString=" >
</asp:HyperLinkField>

In my case this is an app I did not write, but need to modify quickly as we go from test to staging to production etc. That is why I would like to set the string in the web config file. It will be changing a lot.
 
Thanks Jbenson001, but experts-exchange is a pay site looking for cc info etc. I really rather not go down that path. Still looking for a solution.
 
I appreciate your sticking with me jbenson001, but as far as expert-exchange goes it is only free for 7 days and only if I give them my cc info.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top