By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,854 Members | 833 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,854 IT Pros & Developers. It's quick & easy.

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

P: n/a
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.x ml"));

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.x ml"));

DataSet dstXML = new DataSet();

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

Myfirstgrid.DataSource = dstXML;

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

------------------

Maheshkumar.R

Nov 19 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.