473,396 Members | 1,777 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

ASPNET C# TreeView Help

I have a treeview wich is populated from SqlDataSource.

Every thing populates just fine, except that i cant select any of my childnodes,
How do I setup a url to newNode so when i click on my product it will display
them in my contentplace holder???

this is my code sofare:

protected void GetProductsForCategory(TreeNode node)
{

String categoryId = node.Value;
ProductList products = WarehouseDB.GetProductsForCategory(categoryId);
foreach (Product p in products)
{
TreeNode newNode = new TreeNode(p.Name, p.Id);
newNode.PopulateOnDemand = false;
node.ChildNodes.Add(newNode);
newNode.SelectAction = TreeNodeSelectAction.Select;
newNode.NavigateUrl="../Catalog.aspx?DepartmentID=' + Request.QueryString['DepartmentID'] + '&CategoryID=' + Eval('CategoryID')";
}
}

protected void PopulateNode(Object source, TreeNodeEventArgs e)
{
switch (e.Node.Depth)
{
case 0:
GetDepartment(e.Node);
break;
case 1:
GetProductCategories(e.Node);
break;
case 2:
GetProductsForCategory(e.Node);
break;
}
}

Please note that my NavigationUrl works in my former usercontrol CatgeoriesList
i would like to translate it to work in my treeview
Aug 26 '07 #1
1 2111
I have a treeview wich is populated from SqlDataSource.

Every thing populates just fine, except that i cant select any of my childnodes,
How do I setup a url to newNode so when i click on my product it will display
them in my contentplace holder???

this is my code sofare:

protected void GetProductsForCategory(TreeNode node)
{

String categoryId = node.Value;
ProductList products = WarehouseDB.GetProductsForCategory(categoryId);
foreach (Product p in products)
{
TreeNode newNode = new TreeNode(p.Name, p.Id);
newNode.PopulateOnDemand = false;
node.ChildNodes.Add(newNode);
newNode.SelectAction = TreeNodeSelectAction.Select;
newNode.NavigateUrl="../Catalog.aspx?DepartmentID=' + Request.QueryString['DepartmentID'] + '&CategoryID=' + Eval('CategoryID')";
}
}

protected void PopulateNode(Object source, TreeNodeEventArgs e)
{
switch (e.Node.Depth)
{
case 0:
GetDepartment(e.Node);
break;
case 1:
GetProductCategories(e.Node);
break;
case 2:
GetProductsForCategory(e.Node);
break;
}
}

Please note that my NavigationUrl works in my former usercontrol CatgeoriesList
i would like to translate it to work in my treeview

Okay - I have found the solution...
protected void GetProductCategories(TreeNode node)
{
String departmentId = node.Value;
CategoryList categories = WarehouseDB.GetDepartmentCategories(departmentId);
foreach (Category c in categories)
{
TreeNode newNode = new TreeNode(c.Name, c.Id);
newNode.SelectAction = TreeNodeSelectAction.Expand;
newNode.PopulateOnDemand = false;
node.ChildNodes.Add(newNode);
newNode.Target = "contentPlaceHolder";
newNode.NavigateUrl = "../Catalog.aspx?" + "CategoryID=" + c.Id;

}
}

Thanks anyways :)
Aug 26 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Sonia Igla | last post by:
Hi. I need to perform DBLCLK on TreeView Node. I try the following: private static extern int SendMessage(IntPtr hWnd, uint msg, UInt32 wParam, UInt32 lParam); private const UInt32...
3
by: Dan Nash | last post by:
Hi guys I'm trying to get a database connection to MSDE working. The books say I have to use oSql to setup the ASPNET account to work with databases. However, oSql is telling me I've got no...
4
by: Karim El Jed | last post by:
Hi, I'm trying to expand a special Node of my TreeView from Codebehind. I have a TreeView on a page for navigating to another site. On the other tsite here is the same TreeView more precisely a...
3
by: christof | last post by:
I've got a really easy problem, please help me: There are two pages in one I'm creating a TreeView like that: TreeView dbTree = new TreeView(); TreeNode dbTreeRoot = new TreeNode("Root");...
2
by: Matt | last post by:
I have below sitemap as source for treeview that sits on master pages.. Is there a way to limit source for treeview to page level.. When i cruise the pages i would like to see only related nodes...
3
by: William Sullivan | last post by:
I desperately want to replace my hand-made ajax treeview with the 2.0 TreeView. The webpage I'm designing uses the postbacks to dynamically fill the treeview. The reason why I'm doing this is...
0
by: jamie | last post by:
Hi, I hava a sql server with 3 tables in it the first table is self referencing and one other looks up this table and the last table. Table1: StateID|ParentStateID|State| Table2:...
8
by: Matt MacDonald | last post by:
Hi All, I have a form that displays hierarchical categories in a treeview. Ok so far so good. What I was to do is have users be able to select a node in the treeview as part of filling out the...
2
by: makennedy | last post by:
Hi Experts, Please help, I am a newbie to ASP.NET 2.0 may be I am doing something wrong or there may be a bug somewhere. Basically I have a TreeView Control which I have created...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.