request.querystring

  • Thread starter Thread starter Luke Davis
  • Start date Start date
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
 
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
 
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.
 
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
 
Back
Top