Hyperlink in a gridview send 2 values in querystring

Inside a gridview, i am using the following code to create a hyperlink which will send two values in a querystring
to another page.

        <Columns>
            <asp:HyperLinkField  HeaderText="View Games"
                DataNavigateUrlFields="UserName,GameTitle" DataNavigateUrlFormatString  = "~/MemberPages/Players.aspx?UserName={0},GameTitle={1}" Text="View" />
        </Columns>

When I hover over the link, I can see the querystring is .../Players.aspx?UserName=chris, GameTitle=poker

Now, instead of the comma between the two values, there should be an & sign right ?
When I want to receive the 2 on the redirected page, I use request.querystring("UserName") and request.querystring("GameTitle") to populate 2 variables, however the first request.querystring gets the whole string, and there is nothing for the second request. Is this because there is a comma and no & sign ? How do i setup up the link in the grid to send 2 values from the row, and receive them on another page ?
gusdogsAsked:
Who is Participating?
 
sasapopovicConnect With a Mentor Commented:
Your assumption is right. You should replace the comma with the "&" and everything will work just as you want. So here is how you should write it:

        <Columns>
            <asp:HyperLinkField  HeaderText="View Games"
                DataNavigateUrlFields="UserName,GameTitle" DataNavigateUrlFormatString  = "~/MemberPages/Players.aspx?UserName={0}&GameTitle={1}" Text="View" />
        </Columns>

That way when you ask for request.querystring("UserName"), you will get only the username and when you call request.querystring("GameTitle") you will get only the game title.

Regards,
Sasa
0
 
gusdogsAuthor Commented:
What a wolly !! Thanks TheLearnedOne, I was under the impression it wouldn't work without the comma
because there is a comma between the DataNavigateUrlFields !
Thanks.
0
 
gusdogsAuthor Commented:
Sorry, that message was for sasapopovic.
0
Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

 
sasapopovicCommented:
Hi gusdogs,

no problem, I'm glad that helped you.
It would be nice if you would give some points now ;-)

Regards,
Sasa
0
 
gusdogsAuthor Commented:
Haven't I awarded you the points by accepting the answer ?
(Fairly new to EE !)
0
 
sasapopovicCommented:
Yes you did. I wrote that before I saw you accepted answer.
Sorry for that.
0
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.