|
using System;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Ganesh;
public partial class MenuPage : System.Web.UI.Page
{
DBClass ObjDBClass= new DBClass();
public SqlConnection ObjCon = new SqlConnection(ConfigurationManager.AppSettings["ConnectionString"]);
SqlDataAdapter ObjAdapterTab,ObjAdapterMenu;
protected void Page_Load(object sender, EventArgs e)
{
PopulateMenu();
}
private void PopulateMenu()
{
DataSet ds = GetDataSetForMenu();
Menu menu = new Menu();
foreach (DataRow parentItem in ds.Tables["Tabs"].Rows)
{
MenuItem categoryItem = new MenuItem((string)parentItem["TabName"]);
menu.Items.Add(categoryItem);
foreach (DataRow childItem in parentItem.GetChildRows("Menu"))
{
MenuItem childrenItem = new MenuItem((string)childItem["MenuName"]);
categoryItem.ChildItems.Add(childrenItem);
}
}
Panel1.Controls.Add(menu);
Panel1.DataBind();
}
private DataSet GetDataSetForMenu()
{
ObjAdapterTab = new SqlDataAdapter("SELECT * FROM Tabs", ObjCon);
ObjAdapterMenu = new SqlDataAdapter("SELECT * FROM Menus", ObjCon);
DataSet ds = new DataSet();
ObjAdapterTab.Fill(ds, "Tabs");
ObjAdapterMenu.Fill(ds, "Menus");
ds.Relations.Add("Menu",ds.Tables["Tabs"].Columns["TabID"],ds.Tables["Menus"].Columns["TabID"]);
return ds;
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.
A list of licenses authors might use can be found here