I am trying to encode the url using HttpUtility.UrlEncode
,
but not able to make it work. HyperLink
control is in the
template field of gridview.
Can anyone please help me out with this?
I have tried changing the target application and by adding
System.Web
reference to project but still not able to Encode
the url.
Please guide me.
Following is part of my code:-
<asp:HyperLink ID="lnkDetailsPage" runat="server" NavigateUrl='<%# string.Format("~/YellowPages/YellowDetailView.aspx?CustomerId={0}",HttpUtility.UrlEncode(Eval("CustomerId").ToString())) %>'></asp:HyperLink>
Thanks in advance.
Use Server.UrlEncode()
instead. Why do you need to encode your CustomerID?!