Binding to LinqDataSource
Since the Q2 2008 SP1 release RadTreeView supports hierarchical data binding to the LinqDataSource control. This article shows how to do this in Design Time:
-
Create a new Web Site in Visual Studio and copy the Northwind.mdf database in your App_Data folder.
-
Add a new Linq to SQL Classes item named Northwind.dbml:
-
Open Northwind.dbml in design mode and drag the Employees table from Server Explorer. The Employees table is self referencing and suites perfectly for this example:
-
Open Default.aspx in design mode and drag a new RadTreeView instance.
-
Open the smart tag and select "New data source":
-
Choose "LinqDataSource" from the "Data Source Configuration Wizard":
-
Configure the newly created data source to use the NorhtwindDataContext object:
-
Select the "EmployeeID", "LastName" and "ReportsTo" columns from the "Configure Data Source" dialog:
-
Click "Finish" and open the RadTreeView smart tag to complete the configuration.
-
Select "EmployeeID" for the DataFieldID property, "ReportsTo" for the DataFieldParentID property and "LastName" for the DataTextField property:
-
Save your page and run the web site. You should see a page with the following RadTreeView: