hi,
I have a radmenu with sqldatasource.When the user log in the site,the menu will load according to the user rights.I check the user rights from the database.The code below doesn't work for me.How can I achieve this?
private void GetAllChildItems(RadMenuItem itemsList, string MenuId)
I have a radmenu with sqldatasource.When the user log in the site,the menu will load according to the user rights.I check the user rights from the database.The code below doesn't work for me.How can I achieve this?
private void CreateMenuByUser()
{
RadMenu1.Visible = true;
DataTable table = GetDataTable("SELECT * FROM UserRights INNER JOIN Users ON UserRights.UserID = Users.UserID WHERE Users.UserID = '" + Session["UserID"] + "'");
//RadMenuItemCollection menuItems = RadMenu1.Items;
RadMenuItem disabledItems = new RadMenuItem();
foreach (DataRow item in table.Rows)
{
if (bool.Parse(item["rRead"].ToString()) == false)
{
foreach (RadMenuItem menuItem in RadMenu1.Items)-->>>this line cause the error Index was out of the range error
{
if (menuItem.Value == item["MenuID"].ToString()) disabledItems = menuItem;
if (menuItem.Items.Count > 0) GetAllChildItems(menuItem, item["MenuID"].ToString());
}
RadMenu1.Items.Remove(disabledItems);
}
}
}
private void GetAllChildItems(RadMenuItem itemsList, string MenuId)
{
RadMenuItemCollection menuItems = itemsList.Items;
RadMenuItem disabledItems = new RadMenuItem();
foreach (RadMenuItem menuItem in itemsList.Items)
{
if (menuItem.Value == MenuId) disabledItems = menuItem;
}
menuItems.Remove(disabledItems);
}