DataList and Dynamic Button or LinkButton or Hyperlink?

  • Thread starter Thread starter MU
  • Start date Start date
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
 
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!
 
Back
Top