I'm having some trouble with viewstate, perhaps I don't understand how it works.
I have a table and add rows to it dynamically, but when I try to add the rows to the viewstate, the rows are not displayed (added?) in the table.
private void randomPageMethod()
{
...get data & generate row...
ViewState.Add(tr.ID, tr);
tableLSHTime.Rows.AddAt(1, tr);
}
If I remove the ViewState.Add(tr.ID, tr) line,the rows are added, but ofc not preserved.
I would like to use Page_Load like this (when I use viewstate):
protected void Page_Load(object sender, EventArgs e)
{
...code code...
if (IsPostBack)
{
foreach (TableRow tr in ViewState)
{
tableLSHTime.Rows.Add(tr);
}
}
}