欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

常用的在數(shù)據(jù)庫中建立無限級樹形菜單的asp.net代碼

 更新時間:2008年09月26日 17:56:01   作者:  
經(jīng)常在項(xiàng)目中遇到建立無限級樹形菜單展示的效果,這里簡單地做了一個,基本后臺代碼如下
復(fù)制代碼 代碼如下:

private DataTable GetTable(int topid)
{
DataTable dt = null;
try
{
string constr = "server=.;database=tqnpc;uid=sa;pwd=sa";
string selstr = "select * from RW_工作關(guān)系 where main_id=" + topid + "";
SqlConnection con = new SqlConnection(constr);
SqlDataAdapter da = new SqlDataAdapter(selstr, con);
dt = new DataTable();
da.Fill(dt);
}
catch (Exception ex)
{
Response.Write(ex.Message);
}
return dt;
}

protected void MakeTree()
{
DataTable dt = GetTable(0);
try
{
if (dt != null)
{
for (int i = 0; i < dt.Rows.Count; i++)
{
TreeNode tn = new TreeNode();
tn.Text = dt.Rows[i]["MAIN_ID"].ToString();
tn.Value = dt.Rows[i]["REF_ID"].ToString();
tn.SelectAction = TreeNodeSelectAction.Select;
TreeView1.Nodes.Add(tn);
AddTreeNodes(int.Parse(dt.Rows[i]["REF_ID"].ToString()), int.Parse(dt.Rows[i]["REF_ID"].ToString()), tn);
}
}
}
catch (Exception ex)
{
Response.Write(ex.Message);
}
}

這個方法對數(shù)據(jù)庫的結(jié)構(gòu)也有一定的要求,數(shù)據(jù)庫的設(shè)計如下:

相關(guān)文章

最新評論