DataList and Dynamic Button or LinkButton or Hyperlink?

M

MU

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
 
N

Nathan Sokalski

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!
 

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,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top