DataList and Dynamic Button or LinkButton or Hyperlink?

Discussion in 'ASP .Net' started by MU, Jan 19, 2009.

  1. MU

    MU Guest

    Hello,

    I have a DataList populated by a SQLDataSource and I would like to add
    a button to the DataList Item Template so that the user clicks on the
    button and is taken to another page on the site with a Request String
    added to the end like:
    SomePage.aspx?id=3

    How would I add a button (or similar) to the DataList to add that URL
    with the record's ID appended to the end of the URL?

    Thanks
     
    MU, Jan 19, 2009
    #1
    1. Advertising

  2. In the HyperLink, use something like the following:

    NavigateUrl='<%#
    DataBinder.Eval(Container.DataItem,"id","SomePage.aspx?id={0}") %>'

    For sending the user to a page/url, I would suggest using a HyperLink as I
    show above. If you want to use a Button, LinkButton, or ImageButton, you
    would probably use the CommandArgument property and handle the ItemCommand
    event. Hopefully this helps. Good Luck!
    --
    Nathan Sokalski

    http://www.nathansokalski.com/

    "MU" <> wrote in message
    news:...
    > Hello,
    >
    > I have a DataList populated by a SQLDataSource and I would like to add
    > a button to the DataList Item Template so that the user clicks on the
    > button and is taken to another page on the site with a Request String
    > added to the end like:
    > SomePage.aspx?id=3
    >
    > How would I add a button (or similar) to the DataList to add that URL
    > with the record's ID appended to the end of the URL?
    >
    > Thanks
     
    Nathan Sokalski, Jan 19, 2009
    #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. Ken Saganowski

    LinkButton & Hyperlink

    Ken Saganowski, Jan 19, 2004, in forum: ASP .Net
    Replies:
    4
    Views:
    4,236
    Aditya Sen
    Oct 18, 2007
  2. Nevyn Twyll
    Replies:
    8
    Views:
    1,972
  3. =?Utf-8?B?QkxpVFpXaU5H?=

    Adding dynamic LinkButton to dynamic table

    =?Utf-8?B?QkxpVFpXaU5H?=, Jul 27, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    765
    =?Utf-8?B?QkxpVFpXaU5H?=
    Jul 27, 2005
  4. Sathyaish
    Replies:
    3
    Views:
    3,172
    Sathyaish
    Sep 8, 2005
  5. Sathyaish

    Linkbutton does not look like a linkbutton

    Sathyaish, Sep 8, 2005, in forum: ASP .Net Datagrid Control
    Replies:
    1
    Views:
    217
    Sathyaish
    Sep 8, 2005
Loading...

Share This Page