How do I create a xml file from stored session variables

Feb 18 2011 2:57 PM
I am trying to dynamically create a XML file from data when it is stored into a session.
Then retrieve it the XML data from another page and map to a different set of columns.

Is this possible, if so can you give an example of the code.

Code I have written.

this recreates the file but no data is there.

public virtual void Button_Click(object sender, EventArgs args)
{

RegistrationTableControl recControls = (RegistrationTableControl)this.Page.FindControlRecursively("RegistrationTableControl");
if (recControls != null)
{
RegistrationTableControlRow[] rows = recControls.GetSelectedRecordControls();
this.Page.Session["RegistrationTableControl"] = rows;

XmlTextWriter writer = new XmlTextWriter(@"c:\\temp\\reg.xml", System.Text.Encoding.UTF8);



}


public RegistrationTableControlRow[] GetSelectedRecordControls()
{

ArrayList selectedList = new ArrayList(25);
foreach (RegistrationTableControlRow recControl in this.GetRecordControls())
{
if (recControl.RegistrationRecordRowSelection.Checked) {
selectedList.Add(recControl);
}
}
return (RegistrationTableControlRow[])(selectedList.ToArray(Type.GetType("MBSolutions.UI.Controls.ShowRegistrationTablePage.RegistrationTableControlRow")));

}

Answers (1)