数据据库结构:
id subjectname parentid
C#实现代码:
protected void Page_Load(object sender, EventArgs e)
{
DataTable dt = GetTalbeFromDB.GetTable("server=192.168.1.169;uid=sa;pwd=111;database=Military", "select id,subjectname,parentid from SubJect");
if (dt.Rows.Count >0)
{
DataRow [] dr=dt.Select("parentid=0");
for (int i=0;i
{
html.Append("
" + dr[i]["subjectname"]+dr[i]["id"].ToString()+"
");
CreateChildNode(dr[i]["id"].ToString(), dt);
//html.Append();
}
}
Response.Write(html.ToString());
}
private void Cre
id subjectname parentid
C#实现代码:
protected void Page_Load(object sender, EventArgs e)
{
DataTable dt = GetTalbeFromDB.GetTable("server=192.168.1.169;uid=sa;pwd=111;database=Military", "select id,subjectname,parentid from SubJect");
if (dt.Rows.Count >0)
{
DataRow [] dr=dt.Select("parentid=0");
for (int i=0;i
{
html.Append("
" + dr[i]["subjectname"]+dr[i]["id"].ToString()+"
");
CreateChildNode(dr[i]["id"].ToString(), dt);
//html.Append();
}
}
Response.Write(html.ToString());
}
private void Cre