我正在尝试使用xml在编辑模式下更新我的网格,但是我不能这样做。
我只能编辑一个元素,但不知道如何编辑多个元素
我的xml文件如下所示
<CATALOG>
<CD>
<ID>1</ID>
<Application>Dot Net</Application>
<status>Available</status>
<LastUpdate>02-07-2017</LastUpdate>
<Comments>The Rox for July has been loaded</Comments>
</CD>
<CD>
<ID>2</ID>
<Application>JFORWBK</Application>
<status>Available</status>
<LastUpdate>05-07-2017</LastUpdate>
<Comments>DeLorean data has been loaded</Comments>
</CD>
<CD>
<ID>3</ID>
<Application>Codepress</Application>
<status>Open for Input</status>
<LastUpdate>06-07-2017</LastUpdate>
<Comments>The Rox for July has been loaded</Comments>
</CD>
</catalog>当我在编辑模式下打开网格中的数据时,我可以更新单个元素的id
如果我在隐藏字段中有值,我如何一次更新所有元素。
我可以根据in更新我的xml元素。我在一次中只能更新一个元素。
代码如下:
ID = Request.QueryString["sID"];
XmlDocument xmlDoc = new XmlDocument();
string filepathsUpdate = Server.MapPath("Action.xml");
xmlDoc.Load(filepathsUpdate);
XmlNode node = xmlDoc.SelectSingleNode("/CATALOG/CD[ID=" + ID + "]/Action");
node.InnerText = ssplit[0];
xmlDoc.Save(filepathsUpdate);现在如何在服务器端单击C#中的更新按钮,在编辑模式下更新、和注释。
发布于 2017-07-26 20:21:07
在LINQ to XML中,它非常简单:
var id = Request.QueryString["sID"];
XDocument doc = XDocument.Load("Action.xml");
var catalogDescendants = doc.Descendants("CATALOG");
foreach (var cd in catalogDescendants)
{
//you can update the id here for whatever you want
cd.Element("ID").Value = id;
}https://stackoverflow.com/questions/45326315
复制相似问题