HI all,
I have used accordion as my menu in my asp.net web application. but i have created it dynamically by coding . below is the code :-
//Binding the Accordion menu for each and every user according to the authorizations
SqlConnection conMenu = new SqlConnection();
conMenu.ConnectionString = clsProperty.GetConnectionString;
conMenu.Open();
SqlDataAdapter daMenu = new SqlDataAdapter("SELECT DISTINCT UserPermissionDetails.PageGroupId, PageGroupDetails.PageGroupName FROM UserPermissionDetails INNER JOIN " +
"UserGroupDetails ON UserPermissionDetails.UserGroupId = UserGroupDetails.UserGroupId INNER JOIN EmployeeDetails ON UserGroupDetails.UserGroupId = EmployeeDetails.UserGroup INNER JOIN " +
"PageGroupDetails ON UserPermissionDetails.PageGroupId = PageGroupDetails.PageGroupDetailsId WHERE (EmployeeDetails.EmpId =" + Session["EmpId"].ToString() + ") AND (UserPermissionDetails.ViewPage = 1)", conMenu);
DataTable dtMenu = new DataTable();
daMenu.Fill(dtMenu);
if (dtMenu.Rows.Count > 0)
{
AjaxControlToolkit.AccordionPane objPane;
foreach (DataRow row in dtMenu.Rows)
{
objPane = new AjaxControlToolkit.AccordionPane();
objPane.ID = row[0].ToString();
Label lblHeaderTitle = new Label();
lblHeaderTitle.Text = row[1].ToString();
objPane.HeaderContainer.Controls.Add(lblHeaderTitle);
SqlConnection conSubMenu = new SqlConnection();
conSubMenu.ConnectionString = clsProperty.GetConnectionString;
conSubMenu.Open();
//SqlDataAdapter daSubMenu = new SqlDataAdapter("SELECT Name, PageName, PagePath FROM PageDetails WHERE (PageGroup =" + row[0].ToString() + ")", conSubMenu);
SqlDataAdapter daSubMenu = new SqlDataAdapter("SELECT PageDetails.Name, PageDetails.PageName, PageDetails.PagePath FROM PageDetails INNER JOIN UserPermissionDetails ON PageDetails.PageGroup = UserPermissionDetails.PageGroupId AND PageDetails.PageId = UserPermissionDetails.PageId
INNER JOIN UserGroupDetails ON UserPermissionDetails.UserGroupId = UserGroupDetails.UserGroupId INNER JOIN EmployeeDetails ON UserGroupDetails.UserGroupId = EmployeeDetails.UserGroup WHERE (UserPermissionDetails.PageGroupId =" + row[0].ToString() + ") AND
(UserPermissionDetails.ViewPage = 1) AND (EmployeeDetails.EmpId =" + Session["EmpId"].ToString() + ")", conSubMenu);
DataTable dtSubMenu = new DataTable();
daSubMenu.Fill(dtSubMenu);
if (dtSubMenu.Rows.Count > 0)
{
int j = 0;
HyperLink link;
foreach (DataRow rowSubMenu in dtSubMenu.Rows)
{
if (j == 0)
{
link = new HyperLink();
link.ID = rowSubMenu[1].ToString();
link.Text = rowSubMenu[0].ToString();
link.NavigateUrl = rowSubMenu[2].ToString();
objPane.ContentContainer.Controls.Add(link);
j++;
}
else
{
objPane.ContentContainer.Controls.Add(new LiteralControl("<br/>"));
link = new HyperLink();
link.ID = rowSubMenu[1].ToString();
link.Text = rowSubMenu[0].ToString();
link.NavigateUrl = rowSubMenu[2].ToString();
objPane.ContentContainer.Controls.Add(link);
}
}
}
dtSubMenu.Dispose();
daSubMenu.Dispose();
conSubMenu.Close();
Accordion1.Panes.Add(objPane);
}
}
dtMenu.Dispose();
daMenu.Dispose();
conMenu.Close();
. This part is working very well ... it look like the sam in the belo picture :-
but if i am selecting "Center Wise" option under "Report" the page is getting navigated but the menu "report" get closed and shows "Asset" menu open every time. i want to keep it stuck for its child options navigated. how can i do it. plz help.....