Introduction

To create a dynamic menu for the website we would use ASP Menu Control, we can't bind a Menu control directly to database data. Neither the SqlDataSource nor ObjectDataSource controls implement the IHierachicalDataSource interface. Therefore, if we want to represent database data with the Menu control, we need to perform some more work i.e. build the menu items programmatically in the Menu control. This is the approach followed here.


Imagine that you want to represent the contents of the database table with a


Menu control:

This database table represents menu items. The menu items are nested with the help Of the Parent column. For example, the customer menu item is nested under the User management as shown similarly the further nesting can also be done. 

LISTING 1.1 MenuDatabase.aspx

  

protected void Page_Load(object sender, EventArgs e)

    {

        #region Page-Load-Code

           

                if (!Page.IsPostBack)

                    PopulateTreeView();