我是要不同的用户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);
}
}
}