Lets suppose you have a data source in XML like:
1: <Settings>
2: <ElementCollection>
3: <add key="SomeKey" value="SomeValue">
4: <add key="SomeKey" value="SomeValue">
5: </ElementCollection>
6: </Settings>
Now you want to edit the key and values with in the xml element collection.
<asp:XmlDataSource ID="configXmlDataSource" XPath="//add" runat="server" DataFile="~/settings.config"/>
Use the following code in the code-behind
1: // In this code we are getting the Data Item values of the Rad Editor. On UpdateCommand Event we are getting the values of data row in an instance of hash.
2: GridDataItem dataItem = (GridDataItem)e.Item;
3: Hashtable ht = new Hashtable();
4: dataItem.ExtractValues(ht);
5:
6: //Get the node values as per the selected key name:
7: XmlNode AppNode = XmlDataSource1.GetXmlDocument().SelectSingleNode( String.Format("//add[@key='{0}']", key));
8:
9: //Now assign the new value of the Value attribute of the selected node:
10: AppNode.Attributes["value"].Value = ht["value"];
11:
12: //Finally we need to update the xml source file:
13: configXmlDataSource.Save();