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

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

 更新時(shí)間:2008年09月26日 17:56:01   作者:  
經(jīng)常在項(xiàng)目中遇到建立無(wú)限級(jí)樹形菜單展示的效果,這里簡(jiǎn)單地做了一個(gè),基本后臺(tái)代碼如下
復(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);
}
}

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

相關(guān)文章

最新評(píng)論