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:
99032660792!^13[&Joh
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:
...Default3a.aspx?AccountNo=99032660792!^13[&Joh
which doesn't work, but, if I insert the following hand encoded url in the browser, it works
...Default3a.aspx?AccountNo=99032660792!^13[%26Joh

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">
        <Columns>
            <asp:HyperLinkField DataNavigateUrlFields="AccountNo"
                DataNavigateUrlFormatString="Default3a.aspx?AccountNo={0}"
                 Text="Profile" />
            <asp:BoundField DataField="ACCOUNTNO" HeaderText="ACCOUNTNO"
                SortExpression="ACCOUNTNO" />
            <asp:BoundField DataField="COMPANY" HeaderText="COMPANY"
                SortExpression="COMPANY" />
                SortExpression="TempID" />
        </Columns>
    </asp:GridView>
        <asp:ObjectDataSource ID="ObjectDataSource1" runat="server"
            OldValuesParameterFormatString="original_{0}" SelectMethod="GetDistProfile"
            TypeName="DistProfileBLL"></asp:ObjectDataSource>
    </form>
</html>
avoorheisAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

MrAgileCommented:
Hi There,

Here is some good information on the subject.

Sean

http://msdn.microsoft.com/en-us/library/system.web.httpserverutility_methods.aspx
0
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
DataNavigateUrlFormatString="Default3a.aspx?HTMLEncode(AccountNo={0})"
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.
0
MrAgileCommented:
try this,

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

Sean

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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
JavaScript Best Practices

Save hours in development time and avoid common mistakes by learning the best practices to use for JavaScript.

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

thanks again!!!
0
MrAgileCommented:
I'm glad to help.
I recommend this: http://safari.oreilly.com/ You will not need to buy another book.

Sean
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.