复制代码 代码如下:
private void Display(string parentid, String space)
{
DataTable dt;
String strSQL;
strSQL = "Select * From Tree Where ParentID =" + parentid + " Order By ClassID DESC";
SqlDataAdapter sda = new SqlDataAdapter(strSQL, conn);
DataSet ds = new DataSet();
sda.Fill(ds, "Tree");
dt = ds.Tables["Tree"];
if (dt.Rows.Count > 0)
{
foreach (DataRow dr in dt.Rows)
{
strOpinion += space + "<font color=red>[" + dr["JobClassName"].ToString() +"<br>";
Display(dr["ClassID"].ToString(), " " + space,false);
}
}
}
复制代码 代码如下:
public partial class tree_Default : System.Web.UI.Page
{
DataTable dt = null;
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
bind(0);
}
}
public void bind(int pid)
{
DataTable dt1 = bindTree(pid);
foreach (DataRow dr in dt1.Rows)
{
int id = Convert.ToInt32(dr["classid"].ToString());
if (pid == 0)
Response.Write("<div><h3>" + dr["jobclassname"].ToString() + "</h3></div>");
else
Response.Write("<div>"+dr["jobclassname"].ToString()+"</div>");
bind(id);
}
}
public DataTable bindTree(int pid)
{
if (dt == null)
dt = new data().getCatelogs();
DataView root = dt.DefaultView;
root.RowFilter = "Parentid=" + pid;
return root.ToTable();
}
}
新闻热点
疑难解答
图片精选