Click here to Skip to main content
15,892,737 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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:

C#
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

1 solution

 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900