?
Solved

Hyperlink in a gridview send 2 values in querystring

Posted on 2006-05-28
7
Medium Priority
?
2,080 Views
Last Modified: 2011-09-20
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 ?
0
Comment
Question by:gusdogs
  • 3
  • 3
6 Comments
 
LVL 9

Accepted Solution

by:
sasapopovic earned 2000 total points
ID: 16779089
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
 

Author Comment

by:gusdogs
ID: 16782222
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
 

Author Comment

by:gusdogs
ID: 16782266
Sorry, that message was for sasapopovic.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 9

Expert Comment

by:sasapopovic
ID: 16783782
Hi gusdogs,

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

Regards,
Sasa
0
 

Author Comment

by:gusdogs
ID: 16787439
Haven't I awarded you the points by accepting the answer ?
(Fairly new to EE !)
0
 
LVL 9

Expert Comment

by:sasapopovic
ID: 16788778
Yes you did. I wrote that before I saw you accepted answer.
Sorry for that.
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

Sometimes in DotNetNuke module development you want to swap controls within the same module definition.  In doing this DNN (somewhat annoyingly) swaps the Skin and Container definitions to the default admin selections.  To get around this you need t…
ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Suggested Courses

831 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