
Table Of Contents
Introduction
This article demonstrates, how to form the Main menu through database based on given login user. Here I have given the table model and menu formation method. As in the previous article, which discussed XML driven menus generated at runtime, this article focuses on building menu through DataSet.
For demo purpose, I have created the DataSet in runtime.
Menu level Security
We can give the permission to user for a particular screen or action through menu, when an application is loading itself. Like what are all the menus available to the user.
Flow for Menu level Security
The following figure shows the flow of this type of security model.

Table Design
See the table design below, I have added one column USERID. I have designed this table for demo purpose. So I didn't concern about normalization. You can design your table model, but SQL query output should be like MenuID, MenuName, MenuParent, Enable and USERID format.

Login Form
See the Login Form below, you can select a user from here.

Menu Design
The menu will be shown like for USERID='DEMO',

for USERID='AMAL',

Recursive method
A recursive method CreateMenuItems has been used to create all the menu items. I have changed the CreateMenuItems little bit to use a DataSet.

Conclusion
I think this shows how you can implement the security in MainMenu through database and any help, comments are much appreciated!