asp:hyperLink NavigateURL and Eval functions

こ雲淡風輕ζ 提交于 2019-12-02 07:40:20

问题


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?


回答1:


Try with this

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

or

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



回答2:


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

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


来源:https://stackoverflow.com/questions/10981280/asphyperlink-navigateurl-and-eval-functions

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!