New to Telerik UI for ASP.NET AJAX? Download free 30-day trial

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:

  1. Create a new Web Site in Visual Studio and copy the Northwind.mdf database in your App_Data folder.

  2. Add a new Linq to SQL Classes item named Northwind.dbml: RadTreeView Add New Linq to SQL Class Item

  3. 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: RadTreeView Linq Table Employee

  4. Open Default.aspx in design mode and drag a new RadTreeView instance.

  5. Open the smart tag and select "New data source": RadTreeView Choose Data Source

  6. Choose "LinqDataSource" from the "Data Source Configuration Wizard": RadTreeView Choose Data Source Type

  7. Configure the newly created data source to use the NorhtwindDataContext object: RadTreeView Choose Context Object

  8. Select the "EmployeeID", "LastName" and "ReportsTo" columns from the "Configure Data Source" dialog: RadTreeView Configure Data Selection

  9. Click "Finish" and open the RadTreeView smart tag to complete the configuration.

  10. Select "EmployeeID" for the DataFieldID property, "ReportsTo" for the DataFieldParentID property and "LastName" for the DataTextField property: RadTreeView Data Filed ID RadTreeView Data Field Parent ID RadTreeView Text Field

  11. Save your page and run the web site. You should see a page with the following RadTreeView: RadTreeView Bound

See Also

In this article