Asp. NET environment Complete TreeView Usage Class

Source: Internet
Author: User
Tags constructor
Asp.net|treeview #region Statement
//----------------------------------------------------------------------
//
Author: Li Miao (nick.lee)
//
Asp. NET environment, the complete TreeView Control Usage Scenario Class
//
Time: 2005-2-17
Boyorgril@msn.com
qq:16503096
//
//----------------------------------------------------------------------
#endregion
Using System;
#region Custom Namespaces (REUSABLE)
Call itself function Reference namespace
Using NickLee.Web.UI;
Using System.Data;
#endregion

Namespace NickLee.Web.UI
{
<summary>
Summary description of the Menufill.
</summary>
public class Menufill
{

#region class public and private properties
Webdatafill topfill=new Webdatafill ();
Webdatafill secfill=new Webdatafill ();
Webdatafill thirdfill=new Webdatafill ();

private string Topmenu;
private string Secmenu;
private string Thirdmenu;
#endregion

#region Set Property Condition parameters

<summary>
First-level menu SQL statement, example: "SELECT * from Basedata_topmenu order by TOPMENU_PK;"
</summary>
public string sqltopmenustring
{
get{return topmenu;}
set{Topmenu=value;}
}

<summary>
Second-level menu SQL statement, example: "SELECT * from Basedata_secmenu where topmenu_pk="
</summary>
public string sqlsecmenustring
{
get{return secmenu;}
set{Secmenu=value;}
}

<summary>
Level three menu SQL statement, example: "SELECT * from Basedata_thirdmenu where secmenu_pk="
</summary>
public string sqlthirdmenustring
{
get{return thirdmenu;}
set{Thirdmenu=value;}
}

#endregion

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";
#endregion
}


#region TreeView outline, 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 the 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


}
}





Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.