Access values ​​of dynamically generated postback controls

My problem: I have a table dynamically created filled with a lot of dropdownlists. Witch signs are dynamically created.

When the button is pressed, I need to scan all the controls in the table and save their value.

But after the postback, I can no longer access the table, and I have no idea how I can get these values ​​...

Thanks!

+4
source share
2 answers

Dynamically created controls must be created again every time they are passed in the Init or PreInit event (before the ViewState loads), otherwise you cannot get their values.

Some reference links

http://msdn.microsoft.com/en-us/library/ms972976.aspx#viewstate_topic4

http://aspnet.4guysfromrolla.com/articles/081402-1.aspx

http://aspnet.4guysfromrolla.com/articles/082102-1.aspx

+4
source

If the form was published, they should not be in the Request.Forms collection.

Say you named everything starting with dct.

Then you can scroll through the collection and accept the values ​​you need.

You can access the values ​​using Request.Form ("dct_001"), etc.

Since the search is line-based, you can put it in a loop to catch the value.

By the way, this classic ASP approach still works in 4.0

+2
source

Source: https://habr.com/ru/post/1312511/


All Articles