• 软件测试技术
  • 软件测试博客
  • 软件测试视频
  • 开源软件测试技术
  • 软件测试论坛
  • 软件测试沙龙
  • 软件测试资料下载
  • 软件测试杂志
  • 软件测试人才招聘
    暂时没有公告

字号: | 推荐给好友 上一篇 | 下一篇

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

发布: 2007-6-30 23:38 | 作者: admin | 来源: | 查看: 20次 | 进入软件测试论坛讨论

领测软件测试网 #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


}
}



延伸阅读

文章来源于领测软件测试网 https://www.ltesting.net/


关于领测软件测试网 | 领测软件测试网合作伙伴 | 广告服务 | 投稿指南 | 联系我们 | 网站地图 | 友情链接
版权所有(C) 2003-2010 TestAge(领测软件测试网)|领测国际科技(北京)有限公司|软件测试工程师培训网 All Rights Reserved
北京市海淀区中关村南大街9号北京理工科技大厦1402室 京ICP备10010545号-5
技术支持和业务联系:info@testage.com.cn 电话:010-51297073

软件测试 | 领测国际ISTQBISTQB官网TMMiTMMi认证国际软件测试工程师认证领测软件测试网