DataSet in a session var and using it

Sydney101

New Member
I want to put my dataSet in a session var. How can I check if it is set and then use it. That code don't work.<BR><BR> Dim objForumDataSet as New DataSet()<BR> <BR> If Session("ForumDataSet") = Nothing Then<BR> objForumDataSet.ReadXmlSchema(Server.MapPath("Forum.xsd"))<BR> objForumDataSet.ReadXml(Server.MapPath("Forum.xml"))<BR> Session("ForumDataSet") = objForumDataSet<BR> Else<BR> objForumDataSet=Session("ForumDataSet")<BR> End If<BR><BR> Dim objTopicView as New DataView(objForumDataSet.Tables(2))<BR> objTopicView.RowFilter="pstFather='" & Server.URLDecode(Request.QueryString("topic")) & "'"<BR> dgTopic.DataSource=objTopicView<BR> dgTopic.DataBind()<BR> End Sub<BR><BR>It say I cannot check if a dataset is nothing. And if I don't check for the dataset=nothing then i get an error when I create the dataView.<BR><BR>What am I doing wrong ?Why do you want to do that?<BR>Try this instead. Using this will only load it on the first trip to the page. Each subsequent response to the page will use the viewstate.<BR><BR>If Not IsPostBack() Then<BR> 'load dataset here<BR>End If<BR><BR>hth<BR>mattI use the dataSet in other pages.<BR>IsPostBack don't resolve the New dataView problem either. That may be unrelated though
 
Back
Top