Edit this page

Binding to LinqDataSource

Since the Q2 2008 SP1 release RadMenu 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 2008 and copy the Northwind.mdf database in your App_Data folder.

  2. Add a new "Linq to SQL Classes" item named "Northwind.dbml":
    RadMenu LINQ Add New 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:
    RadMenu LINQ Employees Table

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

  5. Open the smart tag and select "New data source":
    RadMenu LINQ Choose DataSource

  6. Choose "LinqDataSource" from the "Data Source Configuration Wizard":
    RadMenu LINQ Choose DataSource Type

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

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

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

  10. Select "EmployeeID" for the DataFieldID property, "ReportsTo" for the DataFieldParentID property and "LastName" for the DataTextField property:
    RadMenu LINQ DataFieldIDRadMenu LINQ DataFieldParentIDRadMenu LINQ DataTextField

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

See Also