Thanx Einar,
It's already solved, I made the mistake of forgetting the New statement
for the listbox in the for each loop.... :-((
-----Original Message-----
From: Einar Paul Qvale [mailto:einar.paul.qvale@f...]
Sent: vrijdag 14 februari 2003 10:33
To: ASPX_Professional
Subject: [aspx_professional] RE: missing dynamically created controls
Make sure you create all the controls in the init event of the page, for
instance the InitializeComponent function.
-----Original Message-----
From: Robert [mailto:rpouleijn@m...]
Sent: 13. februar 2003 18:14
To: ASPX_Professional
Subject: [aspx_professional] missing dynamically created controls
Hi All,
I have a asp.net application where a dynamically create controls on a
page. The controls exist of an number of rows that contain
dropdownlist's,
textbox
's and checkbox's. The controls are added to a placeholder and when the
page
is posted back I recreate all the controls. In this recreation of the
controls things go wrong:
For example I have created in the page load event 4 rows, within each
row 2 dropdownlist's, 4 textbox's and 1 checkbox like this:
[dropdownlist_a1] [dropdownlist_b1] [textbox_a1] [textbox_b1]
[textbox_c1] [textbox_d1] [checkbox_1]
[dropdownlist_a2] [dropdownlist_b2] [textbox_a2] [textbox_b2]
[textbox_c2] [textbox_d2] [checkbox_2]
[dropdownlist_a3] [dropdownlist_b3] [textbox_a3] [textbox_b3]
[textbox_c3] [textbox_d3] [checkbox_3]
[dropdownlist_a4] [dropdownlist_b4] [textbox_a4] [textbox_b4]
[textbox_c4] [textbox_d4] [checkbox_4]
I placed a button on the page to submit the page to force the recreation
of the controls. The first time I hit the button all the controls are
recreated
and visible on the page except the dropdownlist's of the second column.
Only
the dropdownlist of the last row is visible in this column! Like this:
[dropdownlist_a1] [textbox_a1]
[textbox_b1] [textbox_c1] [textbox_d1] [checkbox_1]
[dropdownlist_a2] [textbox_a2]
[textbox_b2] [textbox_c2] [textbox_d2] [checkbox_2]
[dropdownlist_a3] [textbox_a3]
[textbox_b3] [textbox_c3] [textbox_d3] [checkbox_3]
[dropdownlist_a4] [dropdownlist_b4] [textbox_a4] [textbox_b4]
[textbox_c4] [textbox_d4] [checkbox_4]
Hitting the button a second time causes a failure in the recreation of
the controls because the viewstate is mixed up, explained in this
Microsoft
article:
http://msdn.microsoft.com/library/default.asp?url=3D/library/en-
us/vbcon/html/ vbtskaddingcontrolstowebformspageprogrammatically.asp
Only the dropdownlist of the last row in this column is visible no
matter how many records I create. If I only create 1 row the
dropdownlist is visible and everything works fine! No matter how much
time I submit the page.
Does anyone has a suggestion?
Thanks in advance!
Robert