HyperLink with 2 parameters and Server.UrlEncode - can't get it all to work!
Posted on 2010-09-17
Hi I am struggling with the following piece of code:
<asp:HyperLink ID="HyperLink1" Text='<%#DataBinder.Eval(Container.DataItem,"CompanyName")%>' runat="server" NavigateUrl='<%# "displayCompany.aspx?ID=" + DataBinder.Eval(Container.DataItem, "CompanyID") + "&CN=" + Server.UrlEncode(Container.DataItem("CompanyName"))%>' />
It worked fine before I tried to add Server.UrlEncode as CompanyName will often have spaces. The error is:
CS1955: Non-invocable member 'System.Web.UI.IDataItemContainer.DataItem' cannot be used like a method.
Please help me!