Geeks With Blogs

News


Rodney Vinyard - .NET & SQL Developer When all is said and done, more will be said than done

public DataSet MyDataset{

get

{

//------------------------------------------------------------------------------

// get dataset from viewstate

//------------------------------------------------------------------------------

DataSet localDataset = null;

object o = ViewState["viewStateDataset"];

if (o == null)

{

//------------------------------------------------------------------------------

// ViewState is null, dataset get from Db

//------------------------------------------------------------------------------

localDataset = GetFromDatabaseMethod();

}

else

{

//------------------------------------------------------------------------------

// ViewState is not null, read dataset from ViewState

//------------------------------------------------------------------------------

System.IO.StringReader sr = new System.IO.StringReader

( ( string ) ( ViewState [ "viewStateDataset" ] ) );

localDataSet= new DataSet();

localDataSet.ReadXml ( sr );

}

return localDataSet;

}

set

{

//------------------------------------------------------------------------------

// save user changes in viewstate, until they click the Save Button

//------------------------------------------------------------------------------

System.IO.StringWriter sw = new System.IO.StringWriter ( );

value.WriteXml ( sw );

ViewState [ "_dsDerivedElementParents" ] = sw.ToString ( );

}

}

Posted on Saturday, January 27, 2007 6:22 AM XML & Datasets | Back to top


Comments on this post: wrap dataset storage in view state, in a property

# re: wrap dataset storage in view state, in a property
Requesting Gravatar...
This is an excellent blog,very informative and I really appreciate it. It should be going on. Thanks for the information. Keep posting such good topics. Regards.
Left by writing guide on Jun 03, 2010 2:03 AM

Your comment:
 (will show your gravatar)


Copyright © Rodney Vinyard | Powered by: GeeksWithBlogs.net