Connecting Tech Pros Worldwide Help | Site Map

Post Back Predicament

tyler.lloyd@gmail.com
Guest
 
Posts: n/a
#1: Jul 12 '06
Hi,

I am trying to develop an asp.net 2.0 page that dynamically adds
controls (Textbox Fields) to a page depending on items selected from a
treeview. I have however run into a bit of a tricky problem, I require
the controls to be added in a certain order (some controls should be
above others). This causes all kinds of fun when the data is posted
back. If a new control was added and it is positioned before existing
controls on the page it causes the control IDs to become de-synced.

For Example: A user adds five controls and fills in the text fields
then decides to add another control. When the new control is added all
the previously enter data disappears as all the control IDs no longer
match. (I tried setting the Control ID manually; it must be using
another ID)

The only way I can see around this is to pre-populate the whole page
with every control then hide the ones not selected (But this would not
scale well at all). Does anyone have any ideas? Or am I missing
something simple?

Any help would be most appreciated.
Thanks
Tyler

Eliyahu Goldin
Guest
 
Posts: n/a
#2: Jul 12 '06

re: Post Back Predicament


Tyler,

Did you consider putting the controls in a repeater? You could make a
datasource that would hold data necessary for creating the controls and
databind the repeater to that datasource. The controls could be arranged in
the repeater item template and the repeater would build as many items as
required.
--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]

<tyler.lloyd@gmail.comwrote in message
news:1152682410.462027.112860@m73g2000cwd.googlegr oups.com...
Quote:
Hi,
>
I am trying to develop an asp.net 2.0 page that dynamically adds
controls (Textbox Fields) to a page depending on items selected from a
treeview. I have however run into a bit of a tricky problem, I require
the controls to be added in a certain order (some controls should be
above others). This causes all kinds of fun when the data is posted
back. If a new control was added and it is positioned before existing
controls on the page it causes the control IDs to become de-synced.
>
For Example: A user adds five controls and fills in the text fields
then decides to add another control. When the new control is added all
the previously enter data disappears as all the control IDs no longer
match. (I tried setting the Control ID manually; it must be using
another ID)
>
The only way I can see around this is to pre-populate the whole page
with every control then hide the ones not selected (But this would not
scale well at all). Does anyone have any ideas? Or am I missing
something simple?
>
Any help would be most appreciated.
Thanks
Tyler
>

Demetri
Guest
 
Posts: n/a
#3: Jul 12 '06

re: Post Back Predicament


Why are you so concerned with the control ID's?

One solution could be use the Command event instead of the Click event and
then capture the CommandArgument and CommandName to ascertain how to react to
that button in your code.

So let the CommandArgument and CommandName tell your code how to react in
other words.

--
-Demetri


"tyler.lloyd@gmail.com" wrote:
Quote:
Hi,
>
I am trying to develop an asp.net 2.0 page that dynamically adds
controls (Textbox Fields) to a page depending on items selected from a
treeview. I have however run into a bit of a tricky problem, I require
the controls to be added in a certain order (some controls should be
above others). This causes all kinds of fun when the data is posted
back. If a new control was added and it is positioned before existing
controls on the page it causes the control IDs to become de-synced.
>
For Example: A user adds five controls and fills in the text fields
then decides to add another control. When the new control is added all
the previously enter data disappears as all the control IDs no longer
match. (I tried setting the Control ID manually; it must be using
another ID)
>
The only way I can see around this is to pre-populate the whole page
with every control then hide the ones not selected (But this would not
scale well at all). Does anyone have any ideas? Or am I missing
something simple?
>
Any help would be most appreciated.
Thanks
Tyler
>
>
Closed Thread