标题:[求助]TreeView
取消只看楼主
cyyu_ryh
Rank: 8Rank: 8
等 级:贵宾
威 望:45
帖 子:1899
专家分:176
注 册:2006-10-21
结帖率:100%
 问题点数:0 回复次数:0 
[求助]TreeView

我是要不同的用户LEFT中的树显示相应用户能操作的树,显示是可以显示,就是显示得不正确,请帮下忙

private void InitTreeView()
{
string strSqlSelete = "SELECT MenuID,Men_MenuID,Name,Pic,URL,FontColor,State FROM Menu";
DataView dataview = GetTreeDataView(strSqlSelete);
dataview.RowFilter = "Men_MenuID=0";

foreach (DataRowView AddDataView in dataview)
{
TreeNode node = new TreeNode();

node.Text = "<font Color = '" + AddDataView["FontColor"].ToString() + "'>" + AddDataView["Name"].ToString() + "</font>";
node.Value = AddDataView["MenuID"].ToString();
node.NavigateUrl = AddDataView["URL"].ToString();
node.ImageUrl = AddDataView["Pic"].ToString();
node.ImageToolTip = AddDataView["Name"].ToString();

TreeView1.Nodes.Add(node);

AddChildNodes(node);
}

}

private DataView GetTreeDataView(string strSQL)
{
Model.Menu menu = new Model.Menu();
return menu.GetTreeView(strSQL);
}

private void AddChildNodes(TreeNode ChildNode)
{
Model.Menu menu = new Model.Menu();

string Account = Session["Account"].ToString();

int Men_MenuID = Convert.ToInt32(ChildNode.Value);
string select = "select c.MenuID from [user] a left join role b on a.roleid = b.roleid left join Role_Menu c on b.roleid=c.roleid"
+ " where Account = '" + Account + "'";

DataTable dt = menu.ReturnDTabel(select);
for (int i = 0; i < dt.Rows.Count; i++)
{
string menuid = dt.Rows[i]["MenuID"].ToString();
DataView dataview = GetTreeDataView("SELECT MenuID,Men_MenuID,Name,Pic,URL,FontColor,State FROM Menu WHERE MenuID=" + menuid + " and Men_MenuID=" + Men_MenuID + "");

foreach (DataRowView AddChilDataView in dataview)
{
TreeNode Node = new TreeNode();
Node.Text = "<font Color = '" + AddChilDataView["FontColor"].ToString() + "'>" + AddChilDataView["Name"].ToString() + "</font>";
Node.Value = AddChilDataView["MenuID"].ToString();
Node.NavigateUrl = AddChilDataView["URL"].ToString();
Node.ImageUrl = AddChilDataView["Pic"].ToString();
Node.ImageToolTip = AddChilDataView["Name"].ToString();
Node.ToolTip = AddChilDataView["Name"].ToString();
ChildNode.ChildNodes.Add(Node);

AddChildNodes(Node);
}
}
}

搜索更多相关主题的帖子: TreeView 
2007-06-29 13:22



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-151308-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.229407 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved