470,619 Members | 1,841 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,619 developers. It's quick & easy.

postback find dynamic control problem

PCH
I have an c# asp.net (.net 1.1) web page, viewstate on.

The problem I am having is on the button click postback to update.

Heres the situation:

I have an asp table that has 1 header row.

On load I loop through a count, say 0 to 3, and dynamically build rows, into
the asp table.
For each row there are a few cells. for each cell there is/are a textbox
control(s), etc etc.

it builds great, everything works well for display.

When it posts back on a button click, I can no longer access those dynamic
controls.

I tried looping recursively through parent controls, but they dont exit,
they are lost on postback. The recursive loop finds every single control on
the page except those that I build dynamically and add to the ASP table
dynamically.

I also tried the request form object to look at each key. From that I can
find the control keys/values, EXCEPT for those controls I designated as
hidden, which i need!

Any ideas?

Thanks

Nov 18 '05 #1
5 2396
You are correct. The controls are gone after postback.
That's just how it works.
When you dynamically create controls, you are expected to dynamically create
them again upon postback.
It shouldn't be too hard if you design carefully. You should be able to
reuse the code that creates the controls in the first place.

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net
"PCH" <pc***@hotmail.com> wrote in message
news:ux**************@tk2msftngp13.phx.gbl...
I have an c# asp.net (.net 1.1) web page, viewstate on.

The problem I am having is on the button click postback to update.

Heres the situation:

I have an asp table that has 1 header row.

On load I loop through a count, say 0 to 3, and dynamically build rows,
into
the asp table.
For each row there are a few cells. for each cell there is/are a textbox
control(s), etc etc.

it builds great, everything works well for display.

When it posts back on a button click, I can no longer access those dynamic
controls.

I tried looping recursively through parent controls, but they dont exit,
they are lost on postback. The recursive loop finds every single control
on
the page except those that I build dynamically and add to the ASP table
dynamically.

I also tried the request form object to look at each key. From that I can
find the control keys/values, EXCEPT for those controls I designated as
hidden, which i need!

Any ideas?

Thanks

Nov 18 '05 #2
PCH
Greet.

So the only way to get the values is the request form object?

"Steve C. Orr [MVP, MCSD]" <St***@Orr.net> wrote in message
news:OJ**************@tk2msftngp13.phx.gbl...
You are correct. The controls are gone after postback.
That's just how it works.
When you dynamically create controls, you are expected to dynamically create them again upon postback.
It shouldn't be too hard if you design carefully. You should be able to
reuse the code that creates the controls in the first place.

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net
"PCH" <pc***@hotmail.com> wrote in message
news:ux**************@tk2msftngp13.phx.gbl...
I have an c# asp.net (.net 1.1) web page, viewstate on.

The problem I am having is on the button click postback to update.

Heres the situation:

I have an asp table that has 1 header row.

On load I loop through a count, say 0 to 3, and dynamically build rows,
into
the asp table.
For each row there are a few cells. for each cell there is/are a textbox control(s), etc etc.

it builds great, everything works well for display.

When it posts back on a button click, I can no longer access those dynamic controls.

I tried looping recursively through parent controls, but they dont exit,
they are lost on postback. The recursive loop finds every single control on
the page except those that I build dynamically and add to the ASP table
dynamically.

I also tried the request form object to look at each key. From that I can find the control keys/values, EXCEPT for those controls I designated as
hidden, which i need!

Any ideas?

Thanks


Nov 18 '05 #3
No, recreate the controls on postback, but let ASP.NET fill in the user
selected values automatically.
Then you can examine the control values normally.

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net
"PCH" <pc***@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
Greet.

So the only way to get the values is the request form object?

"Steve C. Orr [MVP, MCSD]" <St***@Orr.net> wrote in message
news:OJ**************@tk2msftngp13.phx.gbl...
You are correct. The controls are gone after postback.
That's just how it works.
When you dynamically create controls, you are expected to dynamically

create
them again upon postback.
It shouldn't be too hard if you design carefully. You should be able to
reuse the code that creates the controls in the first place.

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net
"PCH" <pc***@hotmail.com> wrote in message
news:ux**************@tk2msftngp13.phx.gbl...
>I have an c# asp.net (.net 1.1) web page, viewstate on.
>
> The problem I am having is on the button click postback to update.
>
> Heres the situation:
>
> I have an asp table that has 1 header row.
>
> On load I loop through a count, say 0 to 3, and dynamically build rows,
> into
> the asp table.
> For each row there are a few cells. for each cell there is/are a textbox > control(s), etc etc.
>
> it builds great, everything works well for display.
>
> When it posts back on a button click, I can no longer access those dynamic > controls.
>
> I tried looping recursively through parent controls, but they dont
> exit,
> they are lost on postback. The recursive loop finds every single control > on
> the page except those that I build dynamically and add to the ASP table
> dynamically.
>
> I also tried the request form object to look at each key. From that I can > find the control keys/values, EXCEPT for those controls I designated as
> hidden, which i need!
>
> Any ideas?
>
> Thanks
>
>
>



Nov 18 '05 #4
So that means you shouldn't create user controls for Items that use a
Database to retrieve values for it. I.e. you will end up accessing the
database on every postback?
Isn't this a major flaw for user controls?
Is there any around this?

"Steve C. Orr [MVP, MCSD]" <St***@Orr.net> wrote in message news:<OJ**************@tk2msftngp13.phx.gbl>...
You are correct. The controls are gone after postback.
That's just how it works.
When you dynamically create controls, you are expected to dynamically create
them again upon postback.
It shouldn't be too hard if you design carefully. You should be able to
reuse the code that creates the controls in the first place.

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net

Nov 18 '05 #5
Ignore it does remember it.

re***@hotmail.com (ree32) wrote in message news:<76**************************@posting.google. com>...
So that means you shouldn't create user controls for Items that use a
Database to retrieve values for it. I.e. you will end up accessing the
database on every postback?
Isn't this a major flaw for user controls?
Is there any around this?

Nov 18 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Igor Belagorudsky | last post: by
10 posts views Thread by Krista Lemieux | last post: by
13 posts views Thread by Chris Thunell | last post: by
reply views Thread by Tony Hedge | last post: by
5 posts views Thread by vcuankitdotnet | last post: by
2 posts views Thread by =?Utf-8?B?R2lkaQ==?= | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.