Adding Child menu to current Menu structure

Hello Experts,

I have a menu I have created below. I need to add a sub menu to one of the items "menunteg". I am having problems with the syntax of adding the child menu to the parent. Can you please help me. Thanks.

Menu Collection

MenuItem menuadmin = new MenuItem();
            MenuItem menuasc = new MenuItem();
            MenuItem menucpni = new MenuItem();
            MenuItem menugu = new MenuItem();
            MenuItem menuimports = new MenuItem();
            MenuItem menuinsight = new MenuItem();
            MenuItem menunteg = new MenuItem();            
            MenuItem menunws = new MenuItem();
            MenuItem menupfo = new MenuItem();
            MenuItem menuqa = new MenuItem();
            MenuItem menuqwest = new MenuItem();
            MenuItem menureports = new MenuItem();
            MenuItem menuroamex = new MenuItem();
            MenuItem menusocial = new MenuItem();
            MenuItem menutt = new MenuItem();

            menuadmin.Text = "Admin";
            menuadmin.NavigateUrl = "~/secure/admin/default.aspx";
            menuasc.Text = "ASC";
            menuasc.NavigateUrl = "~/secure/asc/default.aspx";
            menucpni.Text = "CPNI";
            menucpni.NavigateUrl = "~/secure/cpni/default.aspx";
            menugu.Text = "GU";
            menugu.NavigateUrl = "~/secure/gu/default.aspx";
            menuimports.Text = "Imports";
            menuimports.NavigateUrl = "~/secure/imports/default.aspx";
            menuinsight.Text = "InSight";
            menuinsight.NavigateUrl = "~/secure/insight/default.aspx";
            menunteg.Text = "NTEG";
            menunteg.NavigateUrl = "~/secure/nteg/default.aspx";            
            menunws.Text = "NWS";
            menunws.NavigateUrl = "~/secure/nws/default.aspx";
            menupfo.Text = "PFO";
            menupfo.NavigateUrl = "~/secure/pfo/default.aspx";
            menuqa.Text = "QA";
            menuqa.NavigateUrl = "~/secure/qa/default.aspx";
            menuqwest.Text = "QWest";
            menuqwest.NavigateUrl = "~/secure/qwest/default.aspx";
            menureports.Text = "Reports";
            menureports.NavigateUrl = "~/secure/reports/default.aspx";
            menuroamex.Text = "RoamEx";
            menuroamex.NavigateUrl = "~/secure/roamex/default.aspx";
            menusocial.Text = "Social";
            menusocial.NavigateUrl = "~/secure/social/default.aspx";
            menutt.Text = "Trouble Tickets";
            menutt.NavigateUrl = "~/secure/tt/default.aspx";

            MenuItemCollection menucollect = new MenuItemCollection();

            return menucollect;

Open in new window

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Carl TawnSystems and Integration DeveloperCommented:
You just need to hold a reference to the parent item and add to its ChildItems collection:

MenuItem menu = new MenuItem("Top-Level");

menu.ChildItems.Add(new MenuItem("Child 1"));
menu.ChildItems.Add(new MenuItem("Child 2"));

Open in new window

Dim item As New MenuItem
item.Text  = something

Refer below article. It gives a good explanation plus example for your reference regarding Adding Menu Items Programmatically. 
PMI ACP® Project Management

Prepare for the PMI Agile Certified Practitioner (PMI-ACP)® exam, which formally recognizes your knowledge of agile principles and your skill with agile techniques.

woodjeAuthor Commented:
Carl tawn,

Thanks for the quick response. I have added your code and I now see the sub menu items but how do I set the text and the NavigateUrl?
i thought you will have that issue and that is the reason i gave that URL for further info.

ANyway hope this helps

MenuItem parentMenuItem= new MenuItem ( menuitemText, menuItemValue );
parentMenuItem.NavigateUrl = webPageUrl;
menuObject.Items.Add ( parentMenuItem);

MenuItem newItem = new MenuItem ( menuitemText, menuItemValue );
newItem.NavigateUrl = webPageUrl;
parentMenuItemObject.ChildItems.Add ( newItem );

Open in new window

Carl TawnSystems and Integration DeveloperCommented:
The same way you would with a top-level item. Simply keep a hold of the reference to the new child item and set the required properties before adding it to the collection:
MenuItem menu = new MenuItem("Top-Level");
MenuItem child;

child = new MenuItem("Child 1");
child.NavigateUrl = "somewhere.aspx";

child = new MenuItem("Child 2");
child.NavigateUrl = "somewhereelse.aspx";

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial

better explanation and example then i provided.
woodjeAuthor Commented:
Thank you
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.