Dynamic Controls Problem

  • Thread starter Elliot Rodriguez
  • Start date
E

Elliot Rodriguez

I have a dropdown list that defines the number of textboxes that appear
within a particular panel. The boxes are created when the dropdownlist's
SelectedIndexChanged event fires on postback.

Also in the form is a datagrid that has some custom validation performed on
values within its rows. The validation is server side but not tied into any
ValidatorControls.

When the form is submitted, if the datagrid contains values that are invalid
according to my rules, the page reloads but my textboxes created in the
previous panel are gone. The dropdownbox still holds its value but the
requisite number of textboxes is no longer there.

I know this is probably a problem with the page events when the controls are
rendered, the problem I cant figure out is how to keep the controls created
during the dropdown's event; Init and Render have already fired.

Any suggestions?

Thanks
 
M

Marina Levit [MVP]

Dynamic controls need to be recreated on every postback.

ASP.NET does this for you for controls you declare on your page because it
knows about them. You need to do it yourself for any dynamic controls added.
 

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,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top