How to pass a parameter to HyperLink in GridView/DataList

How to pass a parameter to HyperLink in GridView/DataList

 

The elegant code is just as follows.

<asp:HyperLink runat="server" NavigateUrl='<%# Eval("ID", "~/theurl.aspx?id={0}") %>' Text='<%# Eval("Title") %>'/>

 

or you could do the concatination like this:

property='<%# 'foo' + Eval("value")%>'

 

But DONOT do this:

property='foo<%#Eval("value")'


Source Link:
ASP.NET ItemTemplates, EVAL() and embedding dynamic values into controls
http://west-wind.com/weblog/posts/5364.aspx

原文地址:https://www.cnblogs.com/rickie/p/403261.html