 |
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:
- Drag a new menu onto your web form.
- Right-click and select Show Smart Tag.
- Open the Choose Data Source drop-down and select New Data Source.
- From the Data Source Configuration Wizard dialog box, select Access database.

- 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:

- 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.

- Click Finish to close the wizard.
- Open the Properties grid for your menu.
- 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.
- Save your page and run it in the browser. Here is the result:

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

|
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:


Now your menu should look like this:

See Also