Here is the example for the Dynamic Menu creation..
U need to create css for the static and dynamic styles,
Important thing is the menu id , Menu ID should be minimum (maintain around 10 charaters) , I spent lot of time to identify the Issue which created by menu id , I was given over 30+ character which makes effect on total Controls which is available on the page..
private Panel CreateDynamicMenuBar(List<string> Permissions, string GroupName)
{
Menu MyMenu = new Menu();
MyMenu.ID = "menu";
MyMenu.Orientation = Orientation.Vertical;
MyMenu.StaticDisplayLevels = 1;
MyMenu.Width = Unit.Percentage(100);
MyMenu.StaticMenuStyle.BorderWidth = Unit.Pixel(0);
MyMenu.StaticMenuItemStyle.HorizontalPadding = Unit.Pixel(0);
MyMenu.CssClass = "treemenustyle2";
MyMenu.StaticMenuItemStyle.CssClass = "StaticItem1";
MyMenu.StaticHoverStyle.CssClass = "StaticHighlight1";
MyMenu.DynamicMenuStyle.CssClass = "ie8fix";
MyMenu.DynamicMenuItemStyle.CssClass = "DynamicItem1";
MyMenu.DynamicHoverStyle.CssClass = "DynamicHighlight1";
MyMenu.DynamicSelectedStyle.CssClass = "DyanamicSelected1";
MyMenu.StaticSelectedStyle.CssClass = "StaticSelected1";
MyMenu.MenuItemClick += new MenuEventHandler(this.Menutasks_SelectedItemChanged);
MyMenu.Items.Clear();
foreach (var v in Permissions)
{
string permissions = v;
MenuItem item = null;
item = new MenuItem( permissions );
item.ToolTip = permissions[1];
MyMenu.Items.Add(item);
}
Panel menupannel = new Panel();
menupannel.Controls.Add(MyMenu);
return menupannel;
}