473,387 Members | 1,516 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

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 2503
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Igor Belagorudsky | last post by:
Hi, i am trying to analyze data submitted in a form but the problem is that when i try to create the controls in code (which is what i want to do), it throws an obect not found exception on...
10
by: Krista Lemieux | last post by:
I'm new to ASP.NET and I'm not use to the way things are handled with this technology. I've been told that when I have a control, I should only bind the data to it once, and not on each post back...
13
by: Chris Thunell | last post by:
I have created several grids dynamically and have added them to different HTML placeholders on a vb.net web form. The grids and controls within them come up and view beautifully when the web page...
6
by: Alan Silver | last post by:
Hello, I have a placeholder, which gets a user control added in when the page first loads. This user control contains a dropdownlist, and I would like to get hold of the value of this drop down...
2
by: Nemo | last post by:
Hi, I have i fishy problem when I have e Repeater with user controls. page_load { if (!isPostBack) { repeater.databind(); }
0
by: Tony Hedge | last post by:
Okay I'm back with another issue ;-) Platform is .NET, VB 2005... I created a templace class that I was successfully able to add as a template column to a GridView control - dynamically!!! So...
5
by: vcuankitdotnet | last post by:
Hi. I have tried to search for this online, but can't find what I'm looking for so I decided to come here. I have a ASP.NET 2.0 website with a masterpage. My .aspx page uses the masterpage. Here is...
2
by: =?Utf-8?B?R2lkaQ==?= | last post by:
Hi, I'm new with ASP .NET, so i'm asking lots of questions latly... I've a web Page, with a button which i've created dynamicly and attached an Click event to it. as i understood here, i need...
3
balabaster
by: balabaster | last post by:
I've got a user control that builds a table of dynamic data based on a :LINQ class holding the data. The data is loaded using the LoadData(DataInstance) method. The table it builds contains a...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.