Click here to Skip to main content
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

Hi,
 
See the below links. It might be help you.
 
C# Creating Dynamic Menus[^]
 
http://forums.aspfree.com/net-development-11/dynamic-buttons-click-event-c-24109.html[^]
 
Thanks,
Viprat
  Permalink  

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

  Print Answers RSS
0 OriginalGriff 6,055
1 DamithSL 4,621
2 Maciej Los 4,087
3 Kornfeld Eliyahu Peter 3,500
4 Sergey Alexandrovich Kryukov 3,294


Advertise | Privacy | Mobile
Web01 | 2.8.141220.1 | Last Updated 19 Oct 2012
Copyright © CodeProject, 1999-2014
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