How do I encode DataNavigateUrlFormatString to send URL that include "&"

I have a master/detail page and am trying to set up the hyperlink on the master page so I can open the detail page with a recordid that looks like:
This string may also include other characters that might not be valid html characters.
I see there is a Server.HTMLEncode(string) function, but, not sure how to use it/where to put it.

Currently, without encoding, the url that gets sent to open the new page looks like:
which doesn't work, but, if I insert the following hand encoded url in the browser, it works

Can the function get included in the DataNavigateUrlFormatString some how, or does it need to go elsewhere?
Here's some of my code from the master page that contains the hyperlink:
    <asp:GridView ID="GridView1" runat="server" DataSourceID="ObjectDataSource1"
            AutoGenerateColumns="False" Caption="Distributor List"  CaptionAlign="Top"
            AllowSorting="True" CellPadding="5" CellSpacing="5">
            <asp:HyperLinkField DataNavigateUrlFields="AccountNo"
                 Text="Profile" />
            <asp:BoundField DataField="ACCOUNTNO" HeaderText="ACCOUNTNO"
                SortExpression="ACCOUNTNO" />
            <asp:BoundField DataField="COMPANY" HeaderText="COMPANY"
                SortExpression="COMPANY" />
                SortExpression="TempID" />
        <asp:ObjectDataSource ID="ObjectDataSource1" runat="server"
            OldValuesParameterFormatString="original_{0}" SelectMethod="GetDistProfile"
Who is Participating?
MrAgileConnect With a Mentor Commented:
try this,

Your using html encode scrap that and try the code below. Let me know how it  goes.


                <asp:HyperLink ID="hypDetails" runat="server" NavigateUrl='<%# "Default3a.aspx?AccountNo=" + HttpUtility.UrlEncode(Eval("AccountNo").ToString())  %>' Text="Details" />
Hi There,

Here is some good information on the subject.

avoorheisAuthor Commented:
Thanks Sean,
I've seen this page, but, since I'm a noob, I'm not sure where/how to use this function.
Would it go into the DataNavigateUrlFormatString or elsewhere?
like this
I did try that and it didn't work, just not sure if this is the right place to use it or if it is, maybe my quotes are wrong.
Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

avoorheisAuthor Commented:
What a mouthful, I'll try and let you know....
avoorheisAuthor Commented:
That did it, thank you so much.
Any recomendations to help me learn more about asp, books, websites, etc.

thanks again!!!
I'm glad to help.
I recommend this: You will not need to buy another book.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.