Search code examples
xmlgridview.net-2.0treeviewxslt

Populating a standard .net 2.0 GridView / TreeView control using XML from a database as opposed to an XML file


At present I am populating a standard .net 2.0 GridView & TreeView control using a physical XML document which uses an XSLT stylesheet. But i need to make the population of the grid more dynamic, while still using the XSLT style sheet

Does anyone know if it is possible to populate a standard .net 2.0 Gridview & TreeView control another way apart from using an a physical XML document?

I currently have some XML code stored in a database. Can i retreive it from the databe, apply XSLT style sheet on it and pass it onto the grid / tree without having to make a physical file?


Solution

  • If you are using an XmlDataSource you can set the Data property to any block of Xml. For example you could have a method which calls a webservice, returns some Xml, performs a transform and then assigns to the Data property. Calling DataBind on your grid will then update. It is important to note that if you have a value set in the DataFile property then this will always take precedence over anything you specify for Data.

    You can use the exact same approach to retrieve some Xml from your database, transform and assign to XmldataSource.Data

    HTH