asp:hyperLink NavigateURL and Eval functions

2020-04-29 13:57发布

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?

2条回答
戒情不戒烟
2楼-- · 2020-04-29 14:01

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

NavigateUrl='<%# string.Format("~/Home.aspx?{0}", HttpUtility.UrlEncode(Eval("U_ID").ToString())) %>'
查看更多
该账号已被封号
3楼-- · 2020-04-29 14:02

Try with this

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

or

 NavigateUrl='<%# "http://home/?" + (string)Eval("U_ID") %>'
查看更多
登录 后发表回答