I have a list of class object that I created as a variable in my deafault.aspx.cs page
List<BoldGauge> boldGauges = new List<BoldGauge>();
I create my object in nessacary function and then add the newly created object to the list so I can retrieve it later as needed.
When I attempt loop through the object later the boldGagues count = 0. I assume I need to either add the List to a session variable or session state.
Does anyone know the best approach for this? There could be numerous different types of controls in multiple lists, so if someone could please recommend an approach that is least expensive, and efficient I would appreciate it.
To persist the list across postbacks, you’ll need to store the list somewhere.
You can store it in the
Session, but a more applicable place might be the ViewState.then get it back later
Note that this is scoped to the page, so if you need the list across pages, use the
Session.