Dynamic Controls

J

Jim Heavey

Hello, I have a web page with a <ASP:Table> control on the form. This
table also has 5 DataListControls on 5 seperate <ASP:TableRow> controls.

In code I am dynamically adding TableRow controls to this Table control.
Depending on the content of the DataRows being added, I will set the
appropriate DataListControls to be visible and set the DataSource.

When The page is displayed on the Form Load, all is well, but when I hit
the "Edit" button on one of the DataListControls, the page re-displays
without running the the "OnItemCommand" event and that control show up as
an empty row on my grid.

I thought that since the DataListControls were on the form (maybe not in
the correct poistion, but they were on the form), that the system would
maintain state. I know that if I were to do a Page.Bind in the FormLoad
method on the postback, that this would probably kill the event, and I have
look closely and I have done no rebinding of any control, all I have done
is place the "missing, but expected to be missing, Table Rows back into the
Table control.

SO I must have a hole in mu understanding of dynamic controls.

Can someone clear up my misunderstanding???

Your assistance is greatly appreciated!!!!
 
N

Natty Gur

Hi,

Dynamic create control should be create every time your page create.
Usually creation of dynamic control happened in Form_load event. Load
event called every time page request and it also the last place on the
page life cycle where you can add event handlers to your dynamic
controls. ViewState maintain data for controls and not maintain
controls.

HTH

Natty Gur[MVP]

blog : http://weblogs.asp.net/ngur
Mobile: +972-(0)58-888377
 

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

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top