views:

222

answers:

3

Hi all,

Can a datareader be stored in a viewstate?

What data can be stored in viewstate?

+1  A: 

I guess DataReader can't be stored. Just like xpathiterator can't.

The thing is - class must be serializable to store it in viewstate.


Quick googling gave me this:

A DataReader is not serializable as XML. If you want to store a result set in ViewState, use a DataTable or DataSet.

Arnis L.
+2  A: 

Any data [serializable] that you need to access during postbacks can be stored in a ViewState.

A DataReader cannot be serialised because is is based on Connected model. So it can't be stored in ViewState.

Also storing huge datatables in ViewState is not advisable. Return only necessary data that you need to show in the current context.

rahul
A: 

you can store in view state anything that is SERIALIZABLE

so no, you can't

Omu