Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C++ C C# ASP ASP.NET Javascript HTML , +
// con.Open();
        SqlDataAdapter dadCategories = new SqlDataAdapter("SELECT ID,Name FROM Category order by Name", con);
        SqlDataAdapter dadSubCat = new SqlDataAdapter("SELECT BD,ID,BName FROM Brand order by BName", con);
 
        // Add the DataTables to the DataSet
        DataSet dsCat = new DataSet();
        using (con)
        {
            con.Open();
            dadCategories.Fill(dsCat, "Category");
            dadSubCat.Fill(dsCat, "Brand");
        }
 
        // Add a DataRelation
        dsCat.Relations.Add("Children", dsCat.Tables["Category"].Columns["ID"], dsCat.Tables["Brand"].Columns["ID"]);
        // Add the Category nodes
        int count = 0;
 
        foreach (DataRow categoryRow in dsCat.Tables["Category"].Rows)
        {
 
            MenuItem mNode = new MenuItem(Convert.ToString(categoryRow["Name"]), "", "", "~/item.aspx?CatID=" + Convert.ToString(categoryRow["ID"]), "_parent");
            Menu1.Items.Add(mNode);
 
            // Get matching Sub Category
            DataRow[] subCatRows = categoryRow.GetChildRows("Children");
            foreach (DataRow row in subCatRows)
            {
                string subCatName = Convert.ToString(row["BName"]);
                MenuItem subCatItems = new MenuItem(subCatName, "", "", "~/item.aspx?CatID=" + Convert.ToString(row["ID"]) + "&BID=" + Convert.ToString(row["BD"]), "_parent");
                Menu1.Items(count).ChildItems.Add(subCatItems);
               
               
                
                
            }
            count = count + 1;
        }
    }
 

 
ERROR:
Non-invocable member 'System.Web.UI.WebControls.Menu.Items' cannot be used like a method
 

 
please help me
Posted 26-Dec-12 19:11pm
Edited 26-Dec-12 19:19pm
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

This is C#. you index items with [] not ().
 
Items[count]
 
That's a guess, it would help if you told us what line has the error.
  Permalink  
Comments
sreeCoderMan at 27-Dec-12 1:56am
   
can you explain 3 table relationship
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Syntax Error :
Menu1.Items(count).ChildItems.Add(subCatItems); // You can't put int value as a parameter of Items
 
see MSDN[^]
 
so it could be like this,
 Menu1.Items(count.ToString()).ChildItems.Add(subCatItems);
  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 7,903
1 Sergey Alexandrovich Kryukov 7,127
2 DamithSL 5,604
3 Manas Bhardwaj 4,986
4 Maciej Los 4,820


Advertise | Privacy | Mobile
Web02 | 2.8.1411023.1 | Last Updated 27 Dec 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