Using a Link Button to redirect to another page by using data from

G

Guest

I'm trying to determine how to create a page with data from the database and
I want to use the link button to have the user click on. Once the user
clicks on the link button I want to transfer them to another page, passing,
for example, the customer id from my database.

How to I create a url for this link button, that includes the page name and
passing the page emp_id=1 as the argument?
 
K

Karl Seguin

Keith:
Your question is a little ambiguous. Is this in a databinding environment?
(ie, you have multiple records that you want to display mutiple links?) or a
single link?

In the first case, i'd use a binding control (repeater/datalist/datagrid,
depending on your needs) and simply do:

<itemTemplate>
<tr>
<td><%# DataBinder.Eval(Container.DataItem, "FirstName") %></td>
<td><a href='edit.aspx?uid=<%# DataBinder.Eval(Container.DataItem,
"UserId") %>'>edit</a></td>
</tr>
</itemTemplate>

in the 2nd case I'd create an HtmlAnchor in the html-->

<a id="logout" runat="Server" />

and in codebehind declare the control:

protected logout as HtmlAnchor

Sub Page_Load
dim ds as DataSet = GetDatabaseData()
logout.Href = "logout.aspx?userId=" +
ds.tables(0).Rows(0)("UserId").ToString()
end sub

in the above example a dataset is overkill for a single value..and you'd
want to do some error checking (what if ds is null for example)

Karl
 

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

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top