I am writing my first asp.net user control.
Displays a list of locations that the user can select. I can load the list of elements into the control, and I can see what location the user chose when the page goes back, but the list itself is lost when the page returns.
I populate the list with an object of type IEnumerable<DetailedLocation>, where DetailedLocationis a class with several fields string. When I try to put a list in the ViewState, I get the 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' is not
marked as serializable.
Of course, my type can be marked as serializable, but this error message is saved. I know that it should be possible to do this work somehow. In the end, I can pass an object of this type to GridView, and the data will be saved after the postback.
How to fix it?
source
share