#region 声明
//----------------------------------------------------------------------
//
// 作者: 李淼(Nick.Lee)
//
// ASP.NET环境下完整的treeview控件使用方案类
//
// 时间:2005-2-17
// QQ:16503096
//
//----------------------------------------------------------------------
#endregion
using System;
#region 自定义命名空间(可重用)
//调用本身函数引用命名空间
using NickLee.Web.UI;
using System.Data;
#endregion
namespace NickLee.Web.UI
{
/// <summary>
/// menuFill 的摘要说明。
/// </summary>
public class menuFill
{
#region 类公共属性和私有属性
webDataFill topFill=new webDataFill();
webDataFill secFill=new webDataFill();
webDataFill thirdFill=new webDataFill();
private string topMenu;
private string secMenu;
private string thirdMenu;
#endregion
#region 设定属性条件参数
/// <summary>
/// 一级菜单sql语句,例:“select * from baseData_topMenu order by topMenu_Pk;”
/// </summary>
public string sqltopMenuString
{
get{ return topMenu;}
set{ topMenu=value;}
}
/// <summary>
/// 二级菜单sql语句,例:“select * from baseData_secMenu where topMenu_PK=”
/// </summary>
public string sqlsecMenuString
{
get{ return secMenu; }
set{ secMenu=value; }
}
/// <summary>
/// 三级菜单sql语句,例:“select * from baseData_thirdMenu where secMenu_PK=”
/// </summary>
public string sqlthirdMenuString
{
get{ return thirdMenu; }
set{ thirdMenu=value; }
}
#endregion
public menuFill()
{
//
// TODO: 在此处添加构造函数逻辑
//
#region 构造函数初始定义
topFill.ConString=System.Configuration.ConfigurationSettings.AppSettings["SqlConnectionString"];
secFill.ConString=System.Configuration.ConfigurationSettings.AppSettings["SqlConnectionString"];
thirdFill.ConString=System.Configuration.ConfigurationSettings.AppSettings["SqlConnectionString"];
topFill.dataTableName="topFill";
secFill.dataTableName="secFill";
thirdFill.dataTableName="thirdFill";
#endregion
}
#region treeview分级显示,用datareader
/*
*
* private void treeviewReader()
{
webDataFill fil1=new webDataFill();
webDataFill fil2=new webDataFill();
webDataFill fil3=new webDataFill();
fil1.ConString="server=localhost;uid=sa;pwd=sa;database=northwind;";
fil2.ConString="server=localhost;uid=sa;pwd=sa;database=northwind;";
fil3.ConString="server=localhost;uid=sa;pwd=sa;database=northwind;";
fil1.sqlQueryString="SELECT CategoryID, CategoryName FROM Categories";
fil1.sqlClientDataReader();
while(fil1.mySqlReader.Read())
{
Microsoft.Web.UI.WebControls.TreeNode topNode=new Microsoft.Web.UI.WebControls.TreeNode();
topNode.ID=fil1.mySqlReader["CategoryID"].ToString();
topNode.Text=fil1.mySqlReader["CategoryName"].ToString();
TreeView1.Nodes.Add(topNode);
fil2.sqlQueryString = "SELECT ProductID, ProductName FROM Products where categoryID="+Convert.ToInt32(fil1.mySqlReader["CategoryID"]);
fil2.sqlClientDataReader();
while(fil2.mySqlReader.Read())
{
Microsoft.Web.UI.WebControls.TreeNode nextNode=new Microsoft.Web.UI.WebControls.TreeNode();
nextNode.Text=fil2.mySqlReader["ProductName"].ToString();
topNode.Nodes.Add(nextNode);
fil3.sqlQueryString = "SELECT ProductID, ProductName FROM Products where ProductID<5";
fil3.sqlClientDataReader();
while(fil3.mySqlReader.Read())
{
Microsoft.Web.UI.WebControls.TreeNode thirdNode=new Microsoft.Web.UI.WebControls.TreeNode();
thirdNode.Text=fil3.mySqlReader["ProductID"].ToString();
thirdNode.CheckBox=true;
// thirdNode.NavigateUrl=fil3.mySqlReader["ProductID"].ToString();
nextNode.Nodes.Add(thirdNode);
}
fil3.mySqlReader.Close();
fil3.mySqlConnection.Close();
}
fil2.mySqlReader.Close();
fil2.mySqlConnection.Close();
}
fil1.mySqlReader.Close();
fil1.mySqlConnection.Close();
}
*/
#endregion
}
}