Form database contents hyperlink

B

Big E

I'm using ASP.Net and SQL Server. I have a table called states. I have 2
forms.
On form 1 is the 50 states in textboxes created with a loop.
I want to have those 50 or 45 or whatever amount of states have a hyperlink.
Once you click the hyperlink it will take the stateId from the click event
and use the Get method to send it to the next page.
Page 2 will simply use the browswer get method to show information based on
that stateid.
So my question is how to create a text hyperlink using a loop that onclick
of hyperlink it opens up the next page like: http://www.etc.com?stateid.
How do I create that hyperlink?

Thanks.
 
L

Lau Lei Cheong

Another way would be to use Literal control and add the content between an
<a> tag.
 
E

Eliyahu Goldin

First of all, if you have a table called states, you probably have there a
record for every state. Then why do you need a loop to create textboxes? You
can use a datagrid or datalist or repeater and databind it to the table.
Even if you for whatever reason want textboxes, you can make a templated
column.

Now, there is a server control called HyperLink You can either use it
instead of the textbox or next to the textbox. You will have to setup in
runtime its property NavigateUrl. If you are using a loop, do it in the
loop. If you switch to a datagrid/datalist/repeater, use either databinding
expression or ItemDataBound event. That is the direction. The details you
can work out yourself.

Eliyahu
 

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

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top