首页 > 编程 > .NET > 正文

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

2024-07-10 12:56:22
字体:
来源:转载
供稿:网友
#region 声明
//----------------------------------------------------------------------
//
// 作者: 李淼(nick.lee)
//
// asp.net环境下完整的treeview控件使用方案类
//
// 时间:2005-2-17
// [email protected]
// 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


}
}



最大的网站源码资源下载站,

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表