// 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; } }
Menu1.Items(count).ChildItems.Add(subCatItems); // You can't put int value as a parameter of Items
Menu1.Items(count.ToString()).ChildItems.Add(subCatItems);
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)