Solved

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

Posted on 2010-09-17
2
732 Views
Last Modified: 2013-11-05
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
Comment
Question by:Lorna70
2 Comments
 
LVL 41

Accepted Solution

by:
guru_sami earned 500 total points
ID: 33703645
Try this:
NavigateUrl='<%# "displayCompany.aspx?ID=" + Eval("CompanyID") + "&CN=" + Server.UrlEncode(Eval("CompanyName").ToString())%>'

Make sure you are convert it ToString
0
 

Author Comment

by:Lorna70
ID: 33708272
Thanks Guru Sami - I knew it had to be something simple lol!
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

791 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question