I have an UpdatePanel and in my updatepanel_Load I have some code which looks like this:
if (!IsPostBack || triggeredRefresh.Value == "1")
{
create hidden fields and add to list using
itemFields.Add(newField);
}
else if ( triggeredCheck.Value == "1" )
{
lookup field values
}
The list is declared at class level using:
List itemFields = new List();
The problem is that whenever I want to lookup values in the hidden fields the list is empty. Why is it empty at this point and how can I fix it?
Thanks
Class level fields are not persisted between postbacks. Use the Session state Collection to persist values. For persisting controls, you can use
<asp:PlaceHolder />.EDIT:
If you are using the
HiddenFieldto just store a single value and access from server side and if it’s not being accessed from client script, you can do something like this.Remove your class level list.
if you do need a list of values, then you can do
if you do need it to be a control (to access from client script) you can do