62,046
社区成员
发帖
与我相关
我的任务
分享
public void GetAll(string yhbh)
{
db=new Database(Database.ConnectionStringLocalTransaction);
Hashtable leafs = new Hashtable();
DataSet ds =db.GetDataSet("select * from yonghu_zhb where sjbh='"+yhbh+"'");
if (ds.Tables[0].Rows.Count>0)
{
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
{
string bh=ds.Tables[0].Rows[i]["bh"].ToString();
GetAll(ds.Tables[0].Rows[i]["bh"].ToString());
}
}
else
{
}
}
protected void Page_Load(object sender, EventArgs e)
{
SqlConnection conn=new SqlConnection("connectionString");
SqlDataAdapter da = new SqlDataAdapter("sqlSelect", conn);
da.Fill(dt);
DataRow[] rows = dt.Select("sjbh=''");
foreach (DataRow row in rows)
{
TreeNode node = new TreeNode();
node.Value = row["yhbh"].ToString();
node.Text = row["id"].ToString();
this.TreeView1.Nodes.Add(node);
this._BindTree(dt, node);
}
}
void _BindTree(DataTable dt, TreeNode parentNode)
{
DataRow[] rows = dt.Select(String.Format("sjbh='{0}'", parentNode.Value));
foreach (DataRow row in rows)
{
TreeNode node = new TreeNode();
node.Value = row["yhbh"].ToString();
node.Text = row["id"].ToString();
parentNode.ChildNodes.Add(node);
this._BindTree(dt, node);
}
}