Table Of Contents
Introduction
This article demonstrates, how to form the Main menu through database based on a 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 purposes, 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 purposes. So I am not concerned 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
a little bit to use a DataSet
.
Conclusion
I think this shows how you can implement the security in MainMenu
through database and any help and/or comments are much appreciated!
License
This article has no explicit license attached to it, but may contain usage terms in the article text or the download files themselves. If in doubt, please contact the author via the discussion board below.
A list of licenses authors might use can be found here.