In doing the following operation (the realization of the column of the infinite-level tree-shaped list), there have been mistakes.
The original code is as follows
String querysql = "Select Id,title,[level],parentid from Newscata where websitekey= ' + Webkey +" ' and IsNull (issetedite r,0)!=1 or editers like '%, ' + uid + ',% ') Order by ID;//sql try {DataSet myset = Sqlserverpro.executeonesqldataset (con string, querysql);//Get result set foreach (DataRow irow in MySet. Tables[0]. Rows) {if (irow["ParentID"]. ToString () = = "0") {irow["parentid"] = DBNull.Value}} Handles exception//for (int i = 0; i < i++) with no parent value//{//for (int j = 0; J < MySet. Tables[0]. Rows.Count; J + +)//{//bool Biaozhi=false;//String x = MySet. Tables[0]. rows[j]["ParentID"]. ToString (); for (int m = 0; m < MySet. Tables[0]. Rows.Count; m++)//{//if (x = = DBNull.Value.ToString () | | | x = = MySet. Tables[0]. rows[m]["id"]. ToString ())//{//Biaozhi = true;//break;//}//}//if (!biaozhi)//{//MySet. Tables[0]. ROWS[J]. Delete (); MySet. Tables[0]. AcceptChanges (); }//}//} myset. Relations.Add ("Noderela", MySet. Tables[0]. columns["id"], myset. Tables[0]. columns["ParentID"]); foreach (DataRow mrow in MySet. Tables[0]. Rows) {if (Mrow.isnull ("ParentID")) {ListItem item = new ListItem (), item. Text = mrow["title"]. ToString (); Item. Value = mrow["id"]. ToString (); MDOWN.ITEMS.ADD (item); Buildsubtreegrant (Mrow, Mdown); Exception ex) {throw new Exception (ex. message); } }
There are two ways to solve this problem.
One is to change the method, which is the safest and safest method. Because this is the ASP.net self belt.
The Code
MySet. Relations.Add ("Noderela", MySet. Tables[0]. columns["id"], myset. Tables[0]. columns["ParentID"]);
Replaced by
MySet. Relations.Add ("Noderela", MySet. Tables[0]. columns["id"], myset. Tables[0]. columns["ParentID"],false);
Another approach is to write your own code processing, as noted in the code above, for up to 10 levels of the column to deal with.