Click here to Skip to main content
15,897,291 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hi all ,

I populated the menu from code behind .Now the problem is this I want to set color of menu and sub-menus differently and on click of sub-menu I want to move on next page differently as per URL.
I have fields in Products as:
ProductID,CategoryID,ProductName, URl

Please help
private void PopulateMenu()
   {
       DataSet ds = GetDataSetForMenu();
       Menu menu = new Menu();
       foreach (DataRow parentItem in ds.Tables["Categories"].Rows)
       {
           MenuItem categoryItem = new MenuItem((string)parentItem["CategoryName"]);
           menu.Items.Add(categoryItem);

           foreach (DataRow childItem in parentItem.GetChildRows("Children"))
           {
               MenuItem childrenItem = new MenuItem((string)childItem["ProductName"]);
               categoryItem.ChildItems.Add(childrenItem);

           }
       }

       Panel1.Controls.Add(menu);
       Panel1.DataBind();
   }

   private DataSet GetDataSetForMenu()
   {

       SqlDataAdapter adCat = new SqlDataAdapter("SELECT * FROM Categories", con);
       SqlDataAdapter adProd = new SqlDataAdapter("SELECT * FROM Products", con);

       DataSet ds = new DataSet();
       adCat.Fill(ds, "Categories");
       adProd.Fill(ds, "Products");
       ds.Relations.Add("Children",
       ds.Tables["Categories"].Columns["CategoryID"],
       ds.Tables["Products"].Columns["CategoryID"]);
       return ds;
   }


and want to shift its orientation as horizontal.
Please help me.

Thanks in Advance.
Posted
Updated 19-Jun-11 21:13pm
v5

1 solution

OP wrote:
I want to set color of menu and sub-menus differently

Use CSS
Using CSS and Styles with the Menu Control[^]
Menu Class[^]
OP wrote:
on click of sub-menu I want to move on next page differently as per URL.

There is property NavigateUrl to assign the URL for the navigation.
MenuItem.NavigateUrl Property[^]
Dynamically set NavigateUrl for a menu item in asp.net c#[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900