Click here to Skip to main content
11,417,390 members (51,938 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# VS2010 menu
Hello everyone. I just cant seem to figure out how to add an event click for a dynamic menu. I'm very noob in using C# so i'm really dumb about this. Here's my adding of menu code:

private void loadCat()
   {
        mnuCategory.Items.Clear();
           int i = 0;
           foreach (DataRow dr in blcategory.LoadCategory().Rows)
           {
               dt = new DataTable();
               cat = Convert.ToString(dr[1]);
 
               MenuItem mniTemp = new MenuItem();
               mniTemp.Text = cat;
 
               mnuCategory.Items.Add(mniTemp);
 
               if (dt != null)
               {
                   //DataTable dt2;
                   Boolean b;
 
                   b = blcategory.LoadByCatRetNull(cat);
 
                   if (b != true )
                   {
                       foreach (DataRow drc in blcategory.LoadByCat(cat).Rows)
                       {
                       mnuCategory.Items[i].ChildItems.Add(new MenuItem
                       {
                           Text = Convert.ToString(drc[1]),
                           NavigateUrl = "~/ItemsByCat.aspx"
                       });
                     
                      
                   }
                   }
 

               }
               else
               {
 
               }
               i += 1;
           }
   }
 
Please I'm very dumb about this and if you guys can teach me a step by step method to do this is greatly appreciated. Just imagine teaching a dumb person. Thank you so much guys!
Posted 18-Oct-12 22:57pm

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

  Permalink  

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

  Print Answers RSS
0 Sascha Lefévre 340
1 Abhinav S 303
2 OriginalGriff 235
3 Sergey Alexandrovich Kryukov 215
4 Richard Deeming 125
0 Sergey Alexandrovich Kryukov 9,345
1 OriginalGriff 7,712
2 Maciej Los 3,758
3 Abhinav S 3,601
4 Sascha Lefévre 3,198


Advertise | Privacy | Mobile
Web01 | 2.8.150427.4 | Last Updated 19 Oct 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100