XmlDataSource1.Data = xmldt.OuterXml;
//XmlDataSource1.DataFile = "C:\\TeamFoundationServer\\Vortex\\MAIN\\Sources\\GUIs\\ServicosV2\\ServicosV2\\XML\\ListaAssuntos.xml";
XmlDataSource1.DataBind();
XmlDataSource1.TransformFile = "C:\\TeamFoundationServer\\Vortex\\MAIN\\Sources\\GUIs\\ServicosV2\\ServicosV2\\xslt\\Assuntos.xslt";
TreeView1.DataSource = XmlDataSource1;
TreeNodeBinding binding = new TreeNodeBinding();
binding.DataMember = "Assunto";
binding.ValueField = "value";
binding.TextField = "name";
TreeView1.DataBindings.Add(binding);
TreeView1.DataBind();
Greetings!
Im trying to bind a XmlDocument to a Treeview using a XmlDataSource and transform the data using a xslt file.
Everything works fine if i use the DataFile and TransformFile and call the files directly like this:
XmlDataSource1.DataFile = "C:\\Path\\filename.xml";
XmlDataSource1.DataBind();
XmlDataSource1.TransformFile = "C:\\Path\\filename.xslt";
But when i try to use a XmlDocument i get the error:
Type 'System.Xml.XmlDocument' in Assembly 'System.Xml,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' is
not marked as serializable.
Description: An
unhandled exception occurred during the execution of the current web
request. Please review the stack trace for more information about the
error and where it originated in the code.
Exception Details: System.Runtime.Serialization.SerializationException:
Type 'System.Xml.XmlDocument' in Assembly 'System.Xml, Version=2.0.0.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089' is not marked as
serializable.
The code i use in this case is
.......
xmldt = (XmlDocument)ViewState["xmlTree"];
.......
XmlDataSource1.Data = xmldt.OuterXml;
XmlDataSource1.DataBind();
XmlDataSource1.TransformFile = "C:\\Path\\filename.xslt";
In both cases i declare the bindings in the source view of the controls and in debbug the xmldt.OuterXml is the correct one.
Can anyone help me decypher this bug?