sd_dracula
sd_dracula

Reputation: 3896

asp:hyperLink NavigateURL and Eval functions

What is the correct syntax to add a Eval() function to the NavigateURL attribute of asp:HyperLink?

I am trying to achieve the below:

NavigateUrl="http://home/?<%# Eval("U_ID") %>"

The link should be "http://home? + the value of U_ID" But the syntax isn't right I know. Whats the correct spelling?

Upvotes: 1

Views: 11774

Answers (2)

ABM Abdul Muttalib
ABM Abdul Muttalib

Reputation: 205

It wasn't works my site. I found the following solution:

NavigateUrl='<%# string.Format("~/Home.aspx?{0}", HttpUtility.UrlEncode(Eval("U_ID").ToString())) %>'

Upvotes: 0

Claudio Redi
Claudio Redi

Reputation: 68400

Try with this

 NavigateUrl='http://home/?<%# Eval("U_ID") %>'

or

 NavigateUrl='<%# "http://home/?" + (string)Eval("U_ID") %>'

Upvotes: 7

Related Questions