I was looking for a quick way to edit an XML config file used in an admin tool and was excited when I started looking into the XmlDataSource class introduced with .NET 2.0. As billed, this class "Represents an XML data source to data-bound controls" - ie: you can use it to bind to a GridView and harness the built in resources of the databinding architecture. The catch, however, is that this data source is basically read-only. You can used it to edit the data, but only by manually manipulating the XmlDataDocument exposed by the data source. Since I was under a time constraint, this wasn't going to work for me . . . That's when I stumbed across Mike Chalily's Updateable Xml DataSource Control. This excellent control reimplements the data source by extending DataSourceControl and overriding the ExecuteDelete, ExecuteUpdate and ExecuteInsert methods. As implemented, this basically works right out of the box, is well documented and has a good sample that covers usage. Execellent resource! I, however, had one other little problem. The XML that needed to be edited was not in a format that could be fed to either XmlDataSource or the updatable version. Since the file is used by a third party control, I also couldn't change the xml file to a more useful format. This problem is addressable in the original version by being allowed to apply an Xsl tranform to the file before loading it to the control. The Updatable version didn't allow this. Therefore, I ended up spending some time extending Mike's control to include the ability to apply a transform both on load and on save to bridge this gap. My updated version of the code is included below . . .
UpdatableXmlDataSourceXsl.zip (57.02 kb)