// csWebMenu - [in] Coalesys.WebMenu.WebMenu object
//
// output:
// none
//
public void LoadWebMenuData(Coalesys.WebMenu.WebMenu csWebMenu)
{
Coalesys.WebMenu.Group csMenuGroup;
// database info
string dbConnString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=";
string dbPathString = Server.MapPath("./SelfReferencedTable.mdb");
string dbSqlString = "SELECT * FROM Nodes ORDER BY ID";
// Initiate OleDb interface
OleDbConnection dbConn = new OleDbConnection(dbConnString + dbPathString);
OleDbCommand dbComm = new OleDbCommand(dbSqlString, dbConn);
OleDbDataAdapter dbAdapter = new OleDbDataAdapter();
dbConn.Open();
// Fill an ADO.NET DataSet
DataSet ds = new DataSet();
dbAdapter.SelectCommand = dbComm;
dbAdapter.Fill(ds, "MenuItems");
dbConn.Close();
// Create the data relation between the ID and Parent_ID columns of the MenuItems table.
// (this is the key to hierarchical navigating in a self-referencing table).
DataRelation dr = ds.Relations.Add("MenuItemHierarchy",
ds.Tables["MenuItems"].Columns["ID"],
ds.Tables["MenuItems"].Columns["Parent_ID"]);
// Start top-down navigation of the MenuItem rows.
foreach(DataRow dbMenuItem in ds.Tables["MenuItems"].Rows)
{
// If the Parent_ID colum is null, then this is a root menu item.
if(dbMenuItem.IsNull("Parent_ID"))
{
// Create a menu group for the root menu item
csMenuGroup = csWebMenu.Groups.Add();
csMenuGroup.Caption = dbMenuItem["Caption"].ToString();
// execute the recursive function to populate all it''''s children.
上一页 [1] [2] [3] [4] 下一页 [C语言系列]NET 中C#的switch语句的语法 [系统软件]托拽Explore中的文件到VB.net的窗口 [系统软件]Boost库在XP+Visual C++.net中的安装 [常用软件]新配色面板:Paint.Net3.0RC1官方下载 [常用软件]用内建的“Net Meeting”聊天 [VB.NET程序]Henry的VB.NET之旅(三)—共享成员 [VB.NET程序]Henry的VB.NET之旅(二)—构造与析构 [VB.NET程序]Henry的VB.NET之旅(一)—失踪的窗体 [VB.NET程序]在托盘上显示Balloon Tooltip(VB.NET) [VB.NET程序]Henry手记-VB.NET中动态加载Treeview节点(二)
|