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

  • Thread starter Thread starter Guest
  • Start date Start date
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?
 
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
 
Back
Top