asp.net - How to fix ViewState serialization error with my custom control? -


i'm writing first asp.net user control.

it displays list of locations user can select from. can load list of locations control, , can see location user selected when page posts back, list lost when page posts back.

i populate list object of type ienumerable<detailedlocation> detailedlocation class several string fields. when try put list viewstate, following error:

type 'system.linq.orderedenumerable`2   [[detailedlocation, at.common, version=1.0.0.0, culture=neutral,  publickeytoken=null],[system.string, mscorlib, version=2.0.0.0,   culture=neutral, publickeytoken=b77a5c561934e089]]' in assembly 'system.core,   version=3.5.0.0, culture=neutral, publickeytoken=b77a5c561934e089' not  marked serializable.  

certainly, type can marked serializable, error message persists. know must possible make work somehow. after all, can pass object of type gridview , data persist thru postback.

how fix this?

if you've marked type serializable, try saving collection list instead of ienumerable. i'm guessing under ienumerable interface sort of linq concrete collection type that's not serializable.


Comments

Popular posts from this blog

python - Scipy curvefit RuntimeError:Optimal parameters not found: Number of calls to function has reached maxfev = 1000 -

c# - How to add a new treeview at the selected node? -

java - netbeans "Please wait - classpath scanning in progress..." -