datatable dt=new datatable() DataView dvData = new DataView(dt); dvData.RowFilter = Condition; ViewState[ViewStatedtName] = dvData;
It means that the object you want to store (DataView) isn't marked with a SerializableAttribute. Now, the reason you're getting this error with ViewState and not with Session is because the ViewState is always serialized but that's not necessarily true of Session. In-Process sessions are stored in the server's memory and require no serialization. SQLServer sessions have to be serialized for storage in a database. So, anytime you want to store an object in the ViewState (or a serialized Session), it must be marked with a SerializableAttribute.
instead of putting dataview to viewstate, put dataview.Table to viewstate. It'll resolve your problem. C# DataView dv = ds.Tables[0].DefaultView; ViewState.Add("key", dv.Table);
dataview.Table
DataView dv = ds.Tables[0].DefaultView; ViewState.Add("key", dv.Table);
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)