Complete TreeView Using Class in the ASP.NET Environment

xiaoxiao2021-03-06  15

#Region declaration

/ / -------------------------------------------------------------------------------------------- ----------------------

//

// Author: Li Miao (Nick.Lee)

//

// ASP.NET Environment Complete TreeView Control Usage Program Class

//

// Time: 2005-2-17

//

Boyorgril@msn.com

// QQ: 16503096

//

/ / -------------------------------------------------------------------------------------------- ----------------------

#ndregion

Using system;

#Region Custom Namespace (reuse)

// Call itself function reference namespace

USING NICKLE.WEB.UI;

Using system.data;

#ndregion

Namespace Nicklee.Web.ui

{

///

/// Menufill's summary description.

///

Public Class Menufill

{

#Region Class Public Properties and Private Attributes

WebDataFill Topfill = new webdatafill ();

WebDataFill Secfill = new webdatafill ();

WebDatafill thirdfill = new webdatafill ();

PRIVATE STRING TOPMENU;

PRIVATE STRING Secmenu;

PRIVATE STRING THIRDMENU;

#ndregion

#Region Settings Properties Condition Parameters

///

/// First level menu SQL statement, example: "SELECT * from basedata_topmenu Order by topmenu_pk;"

///

Public String Sqltopmenustring

{

Get {return topmenu;}

Set {topmenu = value;}

}

///

/// Secondary menu SQL statement, example: "SELECT * from baseData_secmenu where topmenu_pk ="

///

Public String Sqlsecmenustring

{

Get {return second

Set {secmenu = value;}

}

///

/// The three-level menu SQL statement, example: "SELECT * from basedata_thirdmenu where seconda_pk ="

///

Public String Sqlthirdmenustring

{

Get {return.

Set {thirdmenu = value;

}

#ndregion

Public menufill ()

{

//

// TODO: Add constructor logic here

//

#REGION constructor initial definition

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";

#ndregion

}

#REGION TreeView grading display, with 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 ();

}

* /

#ndregion

}

}

转载请注明原文地址:https://www.9cbs.com/read-46241.html

New Post(0)