RadMenu for ASP.NET

SqlDataSource or AccessDataSource Send comments on this topic.
See Also
ASP.NET 2.0 features > Declarative data source support > SqlDataSource or AccessDataSource

Glossary Item Box

The SqlDataSource and AccessDataSource controls are very similar to each other with respect to binding to Telerik RadMenu. In this topic we show an example with the AccessDataSourceControl. The same approach is applicable to SqlDataSource. 

The AccessDataSource control enables you to retrieve data from a Microsoft Access database (.mdb file). You can then use it to populate Telerik RadMenu.

To bind your menu to an instance of an AccessDataSource:

  1. Drag a new menu onto your web form.
  2. Right-click and select Show Smart Tag.
  3. Open the Choose Data Source drop-down and select New Data Source.
    New data source
  4. From the Data Source Configuration Wizard dialog box, select Access database.

    The Data Source Configuration Wizard dialog box
  5. Browse to the location of your MDB file.
    For the purpose of this demonstration we use the "menudata.mdb" file delivered with the Telerik RadMenu quick start framework. It contains a table called "Links" with the following data:
    Access data
  6. Select the "id", "Text" and "parentId" from the Configure the select statement dialog box. This specifies the columns that will be retrieved from the "Links" table.
    The Select Statement dialog box
  7. Click Finish to close the wizard.
  8. Open the Properties grid for your menu.
  9. Click the DataTextField drop-down and select Text. This will specify the column that the Text property of all menu items will be bound to.
    Mapping the DataTextField property
  10. Save your page and run it in the browser. Here is the result:
    The bound data on the menu

If you forget to set the "DataTextField" property your menu will look like this:

Text field without data

Build a hierarchical menu

To build a hierarchical menu, you need to set the DataFieldID and DataFieldParentID properties. Considering the "Links" table above, you should set the DataFieldID to "id" and the DataFieldID to "parentId" as follows:

  • DataFieldID:

DataFieldID

  • DataFieldParentID:

DataFieldParentID

Now your menu should look like this:

Hierarchical menu

 

You can view the code library project on Data Binding for a working demo application.

 

See Also