get submenu

Last post 07-03-2009 1:30 PM by akhhttar. 1 replies.

Sort Posts:

  • get submenu

    07-03-2009, 12:11 AM

    hello in my project i m using menucontrol that is display using wcf services. i get to display main menu but i don't know how to get submenu


    my code is below.



                    for (int i = 0; i < menus.Length; i++)
                    {
                       

                        if (menus[i].Parentid == null)
                        {
                            item = new MenuItem(menus[i].Name);
                            Menu1.Items.Add(item);
                            

                        }
                    }
                      for (int j = 0;j < menus.Length; j++)
                                                            
                          {
                              for (int k = 0; k < j; k++)
                              {
                                  if (menus[j].Parentid == menus[k].Id)
                                  {
                                      Response.Write(menus[j].Name );
                                      Response.Write("////");




                                      //MenuItem childitem = new MenuItem(menus[i].Name);
                                      //item.ChildItems.Add(childitem);
                                  }

                              }

                        }


    how to get display submenu


    Nothing is really over,untill the moment stop trying for it...
    Amitsp(MCTS,MCP)
    sqlreporting.blogspot.com
  • Re: get submenu

    07-03-2009, 1:30 PM
    Answer
    • Contributor
      2,367 point Contributor
    • akhhttar
    • Member since 02-14-2007, 3:17 AM
    • Pakistan - Lahore
    • Posts 352

    Hi,

    What about following logic,


    foreach(MenuItem parentMenuItem in Menu1.Items)

    {

    for (int j = 0;j < menus.Length; j++)

    {

    if (menus[j].Parentid == parentMenuItem.Text)
    {

        parentMenuItem.Items.Add(menus[j]);

    }

    }

    }


    Sorry for any syntax error because I didn't compile this code and also don't write in VS :).


    Thanks

    Muhammad AKhtar Shiekh

    Lets resolve the problem together.

    Please remember to mark the appropriate replies as answer after your question is solved, thanks

    My Blog
Page 1 of 1 (2 items)