aspx:
<asp:TreeView ID="tvNavigator" ExpandDepth="1" PopulateNodesFromClient="true" ShowLines="true"ShowExpandCollapse="true" runat="server" SelectedNodeStyle-BackColor="AliceBlue" />
aspx.cs:
private void ShowNavigatorMenu(int ID,int UserID){
ResponseStore<List<ECS.Business.Foundation.Navigator>> navigatorList = objNavigatorBroker.SelectNodes(ID,UserID);
if (navigatorList.Object != null){
objParentNodesList = navigatorList.Object;
foreach (ECS.Business.Foundation.Navigator treeNode in objParentNodesList.Where(item => item.ID == item.ParentID && item.Type.ToLower() == "Lev".ToLower())){
TreeNode ParentNode = new TreeNode();ParentNode.Text = treeNode.Name.ToString();
ParentNode.Value = treeNode.ID.ToString();
ParentNode.NavigateUrl =
"javascript:LevelClick('" + treeNode.ID + "')";tvNavigator.Nodes.Add(ParentNode);
RecursiveChild(ParentNode);
}
}
}
private void RecursiveChild(TreeNode ParentNode){
if (objParentNodesList.Count(item => item.ID != item.ParentID && item.ParentID.ToString() == ParentNode.Value) > 0){
foreach (ECS.Business.Foundation.Navigator chTreeNode in objParentNodesList.Where(item => item.ID != item.ParentID && item.ParentID.ToString() == ParentNode.Value)){
TreeNode childNode = new TreeNode();childNode.Text = chTreeNode.Name.ToString();
childNode.Value = chTreeNode.ID.ToString();
childNode.NavigateUrl =
"javascript:LevelClick('" + chTreeNode.ID + "')";ParentNode.ChildNodes.Add(childNode);
if (chTreeNode.Type.ToLower() == "Lev".ToLower()){
RecursiveChild(childNode);
}
else{
// show some image for location childNode.NavigateUrl = "javascript:LocationClick('" + chTreeNode.ID+ "')";childNode.ImageUrl =
"~/App_Images/Location.png";}
}
}
}
No comments:
Post a Comment