How can I create different number of button controls?
I'm printing to the screen l开发者_开发知识库ots of entries from my database. I'd like each entry to have it's own button, so I can add that specific entry to my cart (saved in Session[]
).
How can I do it? I'd like to have something like this:
Thank you very much!! :)
You can easily achieve that with a repeater or ListView, put a button in the template and give the button an ID of the backend database entry. When the button is clicked, it fires an event (or if you give a command it fires an ItemCommand event) that you can use to do whatever processing you need...
HTH.
Have you had a look at the Repeater Control?
- Repeater Class
- ASP.NET Repeater control instead of grid
As Brian said, you can add the buttons by using the repeater control. As simple as that.
精彩评论