频道直达 - 专题 - 新闻 - 技巧 - 组网 - 开发 - 安全 - web编程 - 图像 - 操作系统 - 数据库 - 教育 - 旅游 - 健康 - 时尚 - 驱动 - 软件 - 游戏 - 多媒体 - ERP - 讨论组

ASP.NET环境下完整的treeview使用类

来源: 作者: 出处:巧巧读书 2006-10-15 进入讨论组
QQRead:http://www.qqread.com/aspdotnet/n222389.html
  #region 声明
//----------------------------------------------------------------------
//
// 作者: 李淼(Nick.Lee)
//
// ASP.NET环境下完整的treeview控件使用方案类
//
// 时间:2005-2-17
// boyorgril@msn.com
// 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


}
} 更多文章 更多内容请看.NET移动与嵌入式技术.NET开发手册ASP.NET教程专题,或进入讨论组讨论。
收藏此文】【 】【打印】【关闭
相关图文阅读
频道图文推荐
健 康 咨 询
时 尚 咨 询
巧巧读书宗旨
相关专题
最新论坛文章
站内各频道最新更新文档
站内最新制作专题
热门关键字导读
Photoshop教 程照片处理 照片制作 PS快捷键 抠图
计 算 机 故 障XP系统修复
艺 术 与 设 计设计 流媒体 设计欣赏 边框
计 算 机 安 全ARP
站内频道文章精选
巧巧电脑频道编辑信箱  告诉我们您想看的专题或文章