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

Discussion in 'ASP .Net' started by =?Utf-8?B?R1REcml2ZXI=?=, Feb 16, 2005.

  1. 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?

    --
    Sincerely,

    Keith
    =?Utf-8?B?R1REcml2ZXI=?=, Feb 16, 2005
    #1
    1. Advertising

  2. =?Utf-8?B?R1REcml2ZXI=?=

    Karl Seguin Guest

    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

    --
    MY ASP.Net tutorials
    http://www.openmymind.net/


    "GTDriver" <> wrote in message
    news:...
    > 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?
    >
    > --
    > Sincerely,
    >
    > Keith
    Karl Seguin, Feb 16, 2005
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Kevin Spencer

    Re: Link Link Link DANGER WILL ROBINSON!!!

    Kevin Spencer, May 17, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    783
    Kevin Spencer
    May 17, 2005
  2. Steven
    Replies:
    1
    Views:
    5,062
    David Dorward
    Jul 9, 2003
  3. johnjohn
    Replies:
    0
    Views:
    492
    johnjohn
    Sep 6, 2006
  4. kolesdz
    Replies:
    9
    Views:
    515
    Blinky the Shark
    Aug 22, 2007
  5. Sal
    Replies:
    1
    Views:
    362
Loading...

Share This Page