I am trying to store some temporary list data so I can let the user edit them before save to database.
public List<ScheduleEntry> NewScheduleEntry
{
get
{
String PersistentName = "List_ScheduleEntry";
if (ViewState[PersistentName] == null || !(ViewState[PersistentName] is List<ScheduleEntry>))
{
ViewState[PersistentName] = new List<ScheduleEntry>();
}
return ViewState[PersistentName] as List<ScheduleEntry>;
}
}
public List<ScheduleEntry> ListView_CourseScheduleEntry_GetData()
{
return NewScheduleEntry;
}
This is not the first time I use this technic but it is not working. There is no exception and I can see ListView_CourseScheduleEntry_GetData was run until return statement.
But if I change the ViewState to Session (no other change), it works fine. Unfortunately I should not use session here, since it is a page transaction.
Is it possible that the viewstate's Base64 encoding string was broken by the list data?
ScheduleEntryclass marked asSerializable? Do you also add some items to the list?