XML FILE as datasource to Grid view..? not able to remove the nodes..?

  • Thread starter =?iso-8859-1?Q?=BF_Mahesh_Kumar?=
  • Start date
?

=?iso-8859-1?Q?=BF_Mahesh_Kumar?=

I have created a XML file as datasource which i 'm binding to a grid view control.

During runtime I'm capturing items in XML file and displaying in a GRID VIEW control. but i want to remove or flush the XML file content on page load. I tried parentnode.removeall () but no use..

(1) how to clean/delete the XML file nodes on page load for using as DATA SOURCE which again i'm binding to Grid view..??

(2) and also on page refresh my gird duplicating the items from XML file...how to avoid duplication of items in Grid...?

----------------------------------------------------------------code on button click (save)

XmlDocument xdoc = new XmlDocument();

xdoc.Load(Server.MapPath("XMLFILES\\ReferrelGrid.xml"));

XmlElement Parentnode = xdoc.CreateElement("ITEMS");

xdoc.DocumentElement.PrependChild(Parentnode);



XmlElement locationnode = xdoc.CreateElement("VID");

XmlElement statenode = xdoc.CreateElement("YesNo");

XmlText locationtext = xdoc.CreateTextNode(((TextBox)rptrItem.FindControl(chkstr)).Text);

XmlText statetext = xdoc.CreateTextNode("True");



Parentnode.AppendChild(locationnode);

Parentnode.AppendChild(namenode);

Parentnode.AppendChild(statenode);




locationnode.AppendChild(locationtext);

namenode.AppendChild(nametext);

statenode.AppendChild(statetext);



xdoc.Save(Server.MapPath("XMLFILES\\ReferrelGrid.xml"));

DataSet dstXML = new DataSet();

dstXML.ReadXml(Server.MapPath("XMLFILES\\ReferrelGrid.xml"));

Myfirstgrid.DataSource = dstXML;

Myfirstgrid.DataBind(); <<<< ------------------- binding the grid view control to that XML Offline file
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top