Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 752
  • Last Modified:

HyperLink with 2 parameters and Server.UrlEncode - can't get it all to work!

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!
0
Lorna70
Asked:
Lorna70
1 Solution
 
guru_samiCommented:
Try this:
NavigateUrl='<%# "displayCompany.aspx?ID=" + Eval("CompanyID") + "&CN=" + Server.UrlEncode(Eval("CompanyName").ToString())%>'

Make sure you are convert it ToString
0
 
Lorna70Author Commented:
Thanks Guru Sami - I knew it had to be something simple lol!
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now