Dynamically Created Controls Not Firing Events

R

Robert Sheppard

I have been wrestling with this problem for a few days and need some input.
I have created a standard webform that contains a TEXTBOX, BUTTON and a
USERCONTROL. I want to be able to input information into the textbox and
then click the button and have a list of results come back from my database.
The User Control is responsible for outputing the results by accepting a
DataReader object and building a table to show the results.

Pretty simple.

Within this table of results I have a button (at the end of eacy row) that I
want to act as an 'Add' button in order to add the line item to a shopping
cart (or move to a detail screen). I originally was simply dynamically
building ImageButtons and assigning them each a uniqueid and then attaching
them to an event that would do whatever I needed to do for that item
(shopping cart, detail, whatever).

These events do not fire and instead a Postback is generated and the
dynamically attached event goes untouched. I know that performing all this
functionality inside of the Postback will work. I don't really want to do
that however since it makes other things I want to do on the page much more
difficult since I then have all this functionality in the postback that I
only want to execute when I want to create a new list.

This is a very simple concept that seems to have a very difficult solution
in DotNet. I have since found that simply using a hyperlink control and
building a url with my parameters will work but I would really like to find
a way to get this to work.

Any Ideas.

Shep
 

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,989
Messages
2,570,207
Members
46,782
Latest member
ThomasGex

Latest Threads

Top