Protected void Page_Load (object sender, EventArgs e) {if (! IsPostBack) {Bind_ TV (TreeView1.Nodes) ;}# add parent node to region // Add parent node // private void Bind_ TV (TreeNodeCollection tree) {// first add Level 1 parent node uint id = Convert. toUInt32 (Session ["ID"]); // Login User idstring sqlmcount = "select * from account where status = 1 and id = '" + id + "'"; dataTable Trdtmcount = MySqlDbHelper. getDataTable (sqlmcount, null); if (Trdtmcount. rows. count> 0) {TreeNode tn = new TreeNode (); tn. value = Trdtmcount. rows [0] ["id"]. toString (); tn. text = Trdtmcount. rows [0] ["nickname"]. toString (); tree. add (tn); BindSon (Convert. toUInt32 (Trdtmcount. rows [0] ["id"]), tn. childNodes ); // Add a subnode according to the parent node} # endregion # region recursively Add a subnode // private void BindSon (uint fatherid, treeNodeCollection tree) {string sqlMancount = "select id, nickname from account where masterid =" + fatherid + ";"; DataTable sonDT = MySqlDbHelper. getDataTable (sqlMancount, null); DataView dv = new DataView (sonDT); foreach (DataRowView item in dv) {// determine whether this person id has subordinates if (sonDT. rows. count> 0) // There are {TreeNode sontn = new TreeNode (); sontn. value = item ["id"]. toString (); sontn. text = item ["nickname"]. toString (); tree. add (sontn); BindSon (Convert. toUInt32 (item ["id"]), sontn. childNodes) ;}}# endregion