Persisting a Dataset in the ViewState object
Hi,
I'm trying to store a small dataset in the ViewState object, so I don't have to repopulate it every time the form is posted back.
After populating the dataset for the first time, I'm able to do a statement like...
ViewState("ds") = ds.GetXml
which stores the dataset as xml inside a string. No problem.
How then can I repopulate the dataset when the page is posted back?
I've got
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If IsPostBack = False Then
'Do all my dataset population stuff here
ViewState("ds") = ds.GetXml
Else
'populate dataset with html from ViewState string
ds.ReadXml(ViewState("ds"))
End If
Nope. No dice. ASP.NET doesn't want a string passed into the ReadXml method. It wants an XmlReader. I tried messing around with this a little bit, but got no success. You'd think that if you can write a dataset out to a string, you could then read it from a string.
I just want to store a dataset in a ViewState or Session variable. How do I do this???
Thanks.
Aaron
End Sub
|