| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 465 人关注过本帖
标题:[求助]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
快速回复:[求助]TreeView
数据加载中...
 
   



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

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