Last post Jan 02, 2008 03:32 PM by Rinze
Dec 17, 2007 10:26 AM|cmssken1|LINK
Hi. I have decided to use the adapted Treeview control for a project I am working on at the moment. All the control will do is display lists of categories and sub categories, and eventually products at the bottom level. When I load my page up, everything
Treeview Adapter is in it's own .dll file. My code is below. If anyone could give me some pointers and help me out that would be great. I am using C#.
public partial class index : System.Web.UI.Page
protected void Page_Load(object sender, EventArgs e)
protected void PopulateNode(object sender, TreeNodeEventArgs e)
int categoryID = Convert.ToInt32(e.Node.Value);
Category myRootCategory = new Category(categoryID);
CategoryCollection myCategories = new CategoryCollection(myRootCategory.CategoryID);
if (myCategories.Count > 0)
foreach (Category myCategory in myCategories)
TreeNode myNode = new TreeNode(myCategory.Name, myCategory.CategoryID.ToString());
myNode.PopulateOnDemand = true;
myNode.SelectAction = TreeNodeSelectAction.Expand;
On my .aspx page, my treeview control is as follows:
<asp:TreeView ID="relatedVariants" runat="server" PopulateNodesFromClient="true" OnTreeNodePopulate="PopulateNode" EnableClientScript="true"> <Nodes> <asp:TreeNode PopulateOnDemand="true" Text="Root" Value="48" SelectAction="Expand"></asp:TreeNode> </Nodes></asp:TreeView>
"css friendly adapter"
treeview programmatically populate OnAdaptedSelectedNodeChanged OnSelectedNodeChanged
Dec 17, 2007 11:09 AM|cmssken1|LINK
I've managed to get the nodes to expand correctly by adding myNode.Expanded = "false" on the inital load, but this had made the list item a URL now. How can I remove this url so I can click the name of the category and have the list expand without posting
back to the server?
Jan 02, 2008 03:32 PM|Rinze|LINK
Can't u use the Staticdisplaylevels property of the treeview control? It limits the number of menulevels that are fully expanded