Handling Events For Dynamically Created Buttons

N

Nathan Sokalski

I have LinkButtons that are dynamically created in one of the PostBack
events. They must be created in the PostBack event because one of the
variables required to determine which ones to create comes from the event
arguments. Because the LinkButtons are not created in the Init event, they
will not exist when I click them to perform a postback. How do I handle the
events for these LinkButtons? I appreciate any help you can give. Thanks.
 
M

Masudur

I have LinkButtons that are dynamically created in one of the PostBack
events. They must be created in the PostBack event because one of the
variables required to determine which ones to create comes from the event
arguments. Because the LinkButtons are not created in the Init event, they
will not exist when I click them to perform a postback. How do I handle the
events for these LinkButtons? I appreciate any help you can give. Thanks.

Hi...

Once you have created the controls... constract a viewstate variable
or session variable to that you can know that dynamically created
links are exists...
After each post back "on Init" first determine wheither dynamically
added controls exists or not... if exists do create the dynamically
added links again...
asp.net will automatically map the event and fire it...
but make sure the control ids remain same...


Masudur
www.munna.shatkotha.com
www.shatkotha.com
 
N

Nathan Sokalski

That would be fine if the number of dynamically created LinkButtons had a
maximum, but it doesn't. Therefore, I would not know how many to create in
the Init event. Also, is there any site you can give me that has a good
example of how to do this? Thanks.
 

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

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,906
Latest member
SkinfixSkintag

Latest Threads

Top