How to create RouteUrls with databound parameters declaratively?

孤人 提交于 2019-12-04 10:03:40

Use System.Web.UI.Control.GetRouteUrl:

VB:

<asp:HyperLink ID="HyperLinkClient" runat="server"  
    NavigateUrl='<%# GetRouteUrl("ClientRoute", New With {.ClientID = Eval("ClientID")}) %>' > 
    Go to Client details 
</asp:HyperLink>

C#:

<asp:HyperLink ID="HyperLinkClient" runat="server"  
    NavigateUrl='<%# GetRouteUrl("ClientRoute", new {ClientID = Eval("ClientID")}) %>' > 
    Go to Client details 
</asp:HyperLink>

I know it's basically the same as Samu Lan's solution but instead of using .net controls you could use regular HTML anchor control.

<a href='<%# GetRouteUrl("ClientRoute", new {ClientID = Eval("ClientID")}) %>'> 
     Go to Client details
</a>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!