Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. menu index of a certain menu item....

menu index of a certain menu item....

Scheduled Pinned Locked Moved ASP.NET
databasehelp
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    RajpootRohan
    wrote on last edited by
    #1

    Hi to all, I am trying to add the menu items dynamically. But I am stucked in problem. I am unable to find the index of the menu items where menu text is "something".

    public void populate\_menu()
    {
        DataSet ds = GetMenuData();
        foreach(DataRow drow in ds.Tables\["CATEGORY"\].Rows)
        {
            MenuItem masteritem = new MenuItem((string)drow\["category\_name"\]);
            name = masteritem.Text;
            get\_id();
            par\_id = Convert.ToInt32 (ViewState\["p\_id"\]);
            if (par\_id == 0)
            {
                Menu1.Items.Add(masteritem);
            }
            else
            {
                //now find the category whose category\_id is par\_id
                get\_category\_name();
                ca\_name = ViewState\["cname"\].ToString();
                
                //get the menu index where category name is "ca\_name"
                
    
                //then under that category, add this sub category
                Menu1.Items\[0\].ChildItems.Add(masteritem);
            }
        }
    }
    

    please assist me..

    cheers, sneha

    N 1 Reply Last reply
    0
    • R RajpootRohan

      Hi to all, I am trying to add the menu items dynamically. But I am stucked in problem. I am unable to find the index of the menu items where menu text is "something".

      public void populate\_menu()
      {
          DataSet ds = GetMenuData();
          foreach(DataRow drow in ds.Tables\["CATEGORY"\].Rows)
          {
              MenuItem masteritem = new MenuItem((string)drow\["category\_name"\]);
              name = masteritem.Text;
              get\_id();
              par\_id = Convert.ToInt32 (ViewState\["p\_id"\]);
              if (par\_id == 0)
              {
                  Menu1.Items.Add(masteritem);
              }
              else
              {
                  //now find the category whose category\_id is par\_id
                  get\_category\_name();
                  ca\_name = ViewState\["cname"\].ToString();
                  
                  //get the menu index where category name is "ca\_name"
                  
      
                  //then under that category, add this sub category
                  Menu1.Items\[0\].ChildItems.Add(masteritem);
              }
          }
      }
      

      please assist me..

      cheers, sneha

      N Offline
      N Offline
      N a v a n e e t h
      wrote on last edited by
      #2

      I guess you need to maintain a value path and work with Menu.FindItem()[^] method. Other way is to recursively search the menu items and sub items until you get the required item.

      Navaneeth How to use google | Ask smart questions

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups