# Region Declaration
//----------------------------------------------------------------------
//
// Author: Nick. Lee)
//
// Complete Treeview control usage class in ASP. NET Environment
//
// Time: 2005-2-17
// Boyorgril@msn.com
// QQ: 16503096
//
//----------------------------------------------------------------------
# Endregion
Using system;
# Region custom namespace (reusable)
// Call the function itself to reference the namespace
Using nicklee. Web. UI;
Using system. Data;
# Endregion
Namespace nicklee. Web. UI
{
/// <Summary>
/// Summary of menufill.
/// </Summary>
Public class menufill
{
# Region Public and Private attributes
Webdatafill topfill = new webdatafill ();
Webdatafill secfill = new webdatafill ();
Webdatafill thirdfill = new webdatafill ();
Private string topmenu;
Private string secmenu;
Private string thirdmenu;
# Endregion
# Region set attribute Condition Parameters
/// <Summary>
/// SQL statement of the first-level menu, for example, "select * From basedata_topmenu order by topmenu_pk ;"
/// </Summary>
Public String sqltopmenustring
{
Get {return topmenu ;}
Set {topmenu = value ;}
}
/// <Summary>
/// SQL statement of the second-level menu, for example, "select * From basedata_secmenu where topmenu_pk ="
/// </Summary>
Public String sqlsecmenustring
{
Get {return secmenu ;}
Set {secmenu = value ;}
}
/// <Summary>
/// Three-level menu SQL statement, for example, "select * From basedata_thirdmenu where secmenu_pk ="
/// </Summary>
Public String sqlthirdmenustring
{
Get {return thirdmenu ;}
Set {thirdmenu = value ;}
}
# Endregion
Public menufill ()
{
//
// Todo: add the constructor logic here
//
# Initial definition of region Constructor
Topfill. constring = system. configuration. configurationsettings. deleettings ["sqlconnectionstring"];
Secfill. constring = system. configuration. configurationsettings. deleettings ["sqlconnectionstring"];
Thirdfill. constring = system. configuration. configurationsettings. deleettings ["sqlconnectionstring"];
Topfill. datatablename = "topfill ";
Secfill. datatablename = "secfill ";
Thirdfill. datatablename = "thirdfill ";
# Endregion
}
# Region Treeview hierarchical 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 ();
}
*/
# Endregion
}
}