1、c#加载树代码例子using System;using System.Collections.Generic;using System.Web;using System.Data;using System.Data.Common;using System.Web.SessionState;using System.Text;using eMIS;using eMIS.Data;public class GetTreeHtml : IHttpHandler , IRequiresSessionStatepublic void ProcessRequest (HttpContext context
2、)string s;int i;string nid = context.Request.QueryString“nid“.ToString();s = context.Request.QueryString“fields“.ToString();string fields = s.Split(,);string table = context.Request.QueryString“table“.ToString();int level = int.Parse(context.Request.QueryString“level“.ToString();string parentValues
3、= context.Request.QueryString“values“.ToString();string values = parentValues.Split(,);string condition = context.Request.QueryString“con“.ToString();bool iscom = (context.Request.QueryString“count“.ToString() = “1“);string unit = context.Request.QueryString“unit“.ToString();bool IsParent;bool IsLas
4、t;int IsDisabled;string newnid;string wwwroot = context.Request.ApplicationPath;if (wwwroot = “/“) wwwroot = “;string imgpath = wwwroot + “/Common6/Code/Elements/Tree/Images“;StringBuilder sb = new StringBuilder();sb.Append(“);string sqlwhere;string sql = “select distinct “ + fieldslevel + “ from “
5、+ table ;if (condition = “)sqlwhere = “ where 1=1 “;elsesqlwhere = “ where “ + condition + “ “;for (i=1;i“);sb.Append(“);sb.Append(“);sb.Append(“);sb.Append(“);sb.Append(“);if (iscom)count = “ + getCount(dm.Operator,table,sqlwhere + “ and “ + fieldslevel + “=“ + desc + “) + “;elsecount = “;if (IsPar
6、ent)sb.Append(“ + desc + unit + count + “);elsesb.Append(“ + desc + unit +count + “);sb.Append(“);if (IsParent)sb.Append(“);sb.Append(“); sb.Append(“);context.Response.Write(sb.ToString();private string getCount(eDbOperator dbOperator,string table,string w)string ret = “0“;DbDataReader r = dbOperator.ExecuteReader(“select count(*) from “ + table + w);if(r.Read()ret =r0.ToString();r.Close();return ret;public bool IsReusablegetreturn false;