request.querystring

L

Luke Davis

I just started with Visual Web Developer, and see if you can help me out
with this. I want to generate a gridview from a table in a database and
each of the rows will be linked to the same page with the exception that the
URL has a variable in it. I know how to retrieve the variable in ASP.NET
from the URL but how do I setup the GridView to have every row be linked to
something like this:

If the row contains "Sacremento" it should be linked to
http://domain/Default.aspx?city=Sacramento.
For the row containing "Fresno" it should be linked to
http://domain/Default.aspx?city=Fresno.

is there a way of automating this?

Right now I'm thinking the Grid will be the result of a SELECT city FROM
states.dbo.citylevel SQL query.

Thanks,


--
Luke Davis, MCSE: Security
DEM Networks - Senior Systems Architect
7225 N First, Suite 105
Fresno, CA 93720
Office: 1 (559) 439-1000
Fax: 1 (866) 640-2041
www.demnetworks.com
 
B

Bruno Piovan

Hi Luke,
try to use a HyperLinkColumn liek the code below:

<Columns>
<asp:HyperLinkField DataNavigateUrlFields="City"
DataNavigateUrlFormatString="http://domain/Default.aspx?city={0}"
DataTextField="City" />
</Columns>

once you bind the datatable to this gridview, it will have a link with only
the city changing.

I hope it helps,
Bruno
 
L

Luke Davis

That's exactly what I was looking for. And if I want to add in more
information into the URL that is in that table, such as state, which is also
databound, how would I do that? (For example the column in the db table is
called "state" and that is shown as well)

Thanks again, that makes sense.
 
B

Bruno Piovan

try to add the columns you'll use in the url, and then use the parameters in
the DataNavigateUrlFormatString starting from zero, example:

DataNavigateUrlFields = "city,state"
DataNavigateUrlFormatString =
"http://domain/Default.aspx?city={0}&state={1}"

Let me know if it works,
Bruno
 
L

Luke Davis

Works great.



Bruno Piovan said:
try to add the columns you'll use in the url, and then use the parameters
in the DataNavigateUrlFormatString starting from zero, example:

DataNavigateUrlFields = "city,state"
DataNavigateUrlFormatString =
"http://domain/Default.aspx?city={0}&state={1}"

Let me know if it works,
Bruno
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,780
Messages
2,569,608
Members
45,241
Latest member
Lisa1997

Latest Threads

Top