Just check the following snippet of code and let me know whether this is
usefule to you
private void PopulateMenu()
{
DataSet ds = GetDataSetFromD atabase();
Menu menu = new Menu();
foreach (DataRow parentItem in ds.Tables["Categories "].Rows)
{
MenuItem categoryItem = new MenuItem((strin g)parentItem["CategoryNa me"]);
menu.Items.Add( categoryItem);
foreach (DataRow childItem in parentItem.GetC hildRows("Child ren"))
{
MenuItem childrenItem = new MenuItem((strin g)childItem["ProductNam e"]);
categoryItem.Ch ildItems.Add(ch ildrenItem);
}
}
}
private DataSet GetDataFromData base()
{
SqlConnection myConnection = new SqlConnection(G etConnectionStr ing());
SqlDataAdapter adCat = new SqlDataAdapter( "SELECT * FROM Categories",
myConnection);
SqlDataAdapter adProd = new SqlDataAdapter( "SELECT * FROM Products",
myConnection);
DataSet ds = new DataSet();
adCat.Fill(ds, "Categories ");
adProd.Fill(ds, "Products") ;
ds.Relations.Ad d("Children",
ds.Tables["Categories "].Columns["CategoryID "],
ds.Tables["Products"].Columns["CategoryID "]);
return ds;
}
--
Thanks & Regards,
Sundar Narasimman
Technology Specialist
"MMA" wrote:
How do I populate the menu control in 2.0 from a database. I know this can be
done with the Tree Control. Any code snippets? Thanks in advance.