How do I data bind a tree to a hierarchical DataSet?

Problem Statement

Users must be allowed to navigate through application features or information categorized from broad categories down to more finely-grained tasks or reports.  The categorizations can be managed through a relational database, which permits superusers the ability to modify the navigation experience available to users without having to redeploy your application.

Your application loads information about these categories using an ADO.NET DataSet, having DataRelations between one or more DataTables which have a parent-child relationship.  You want these relationships to be automatically reflected in the structure of your application's navigational interface.

Infragistics Solutions

ASP.NET     Windows Forms    
 

Add a WebTree control and an XmlDataSource control to your Web page.  Set the WebTree's DataSource property to use the XmlDataSource.  You will set the Data property on the XmlDataSource to an XML string serialized from your hierarchical DataSet by the DataSet's WriteXml method.  You will also set the TransformFile on the XmlDataSource to an XSLT style sheet file you add to your Web site.  This XSLT style sheet is responsible for transforming from the very flat schema in which WriteXml serializes a DataSet into the hierarchical schema that coordinates parent-child elements based on common values in the fields relating the two elements together.

Edit the node bindings of the WebTree to customize which columns are used for each node's text label, target URL, image URL and other properties.  These values can be taken from the inner text or attribute values of the post-transform XML the WebTree loads from the XmlDataSource.

The XmlDataSource control only supports one-way data binding.  Therefore to affect two-way data binding, you must handle events WebTree fires to manually add, update or delete rows within your DataSet.

Other Solutions in the Data Binding Category

More Scenario Solutions...