Advertisement

05.10.2008 at 04:45AM PDT, ID: 23391507
[x]
Attachment Details

Building a Dynamic Tree View with Checkboxes.

Asked by copyPasteGhost in Programming for ASP.NET, .NET, C# Programming Language

Tags: asp.net, C#

here is my table struture. in SQL Server 2005

D (primary key, identity)       ParentID       OwnerID            LanguageID                WordPhrase
1                                                1                    0                       EN                          Restaurant
2                                                1                    0                       FR                           Restaurant
3                                                3                    1                       EN                             American
4                                                3                    1                       FR                             Américain
5                                                5                    1                       EN                             Italian
6                                                5                    1                       FR                             Italien
7                                                7                    1                       EN                             Greek
8                                                7                    1                       FR                               Grec
9                                                9                    0                       EN                           Mechanic  
10                                              9                    0                       FR                           Mécanique
11                                             11                    9                       EN                             Sports Utility Vehicle
12                                             11                    9                       FR                             Véhicule Utilitaire Sportif
13                                             13                    9                       EN                             Cars
14                                             13                    9                       FR                             Automobile


I want to build a tree view with this data I want it to look like this: (subsitute - for the checkbox)
Categories
    -Resturant
          -American
          -Italian
          -Greek
    -Mechanic  
          -Sports Utility Vehicle
          -Cars


I also have a drop down list called ddlMax defined as:

ddlMax.DataSource = new string[] {"1","2","3","4","5","6" };

What I would like to have happen is:

1) build the tree view from the data in the database language independently (Ex. if session["lang"] = "en" then display all the english categories so on and so forth....)

2) Establish a check_changed (or something) on the tree view to count how many categories where selected and check that against the SelectedValue of ddlMax.

Thanks in advance for all your continued support!
GhostStart Free Trial
 
Keywords: Building a Dynamic Tree View with Ch…
 
Loading Advertisement...
 
[+][-]05.10.2008 at 05:04AM PDT, ID: 21538649

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.10.2008 at 05:09AM PDT, ID: 21538662

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.10.2008 at 05:29AM PDT, ID: 21538742

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Programming for ASP.NET, .NET, C# Programming Language
Tags: asp.net, C#
Sign Up Now!
Solution Provided By: DarkoLord
Participating Experts: 1
Solution Grade: A
 
 
[+][-]05.29.2008 at 02:47PM PDT, ID: 21673587

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
Microsoft
  • Internet Protocols
  • Applications
  • Development
  • OS
  • Hardware
  • Windows Security
Apple
  • Operating Systems
  • Hardware
  • Programming
  • Networking
  • Software
Internet
  • Search Engines
  • File Sharing
  • WebTrends / Stats
  • Spy / Ad Blockers
  • Web Browsers
  • New Net Users
  • Web Development
  • Chat / IM
  • Anti Spam
  • Web Servers
  • Anti-Virus
  • Email Clients
Gamers
  • Tips
  • Online / MMORPG
  • Puzzle
  • Emulators
  • Action / Adventure
  • Role Playing
  • Consoles
  • Game Programming
  • Strategy
  • Sports
  • Misc
  • Computer Games
Digital Living
  • Hardware
  • Automotive
  • New Net Users
  • New Users
  • Software
  • Digital Music
  • Gaming World
  • Home Security
  • Apple
  • Networking Hardware
Virus & Spyware
  • Vulnerabilities
  • IDS
  • Encryption
  • Anti-Virus
  • Operating Systems Security
  • Software Firewalls
  • WebApplications
  • Cell Phones
  • Operating Systems
  • Internet
  • Hardware Firewalls
Hardware
  • Displays / Monitors
  • Handhelds / PDAs
  • Components
  • Peripherals
  • Laptops/Notebooks
  • Servers
  • Misc
  • Apple
  • Embedded Hardware
  • Networking Hardware
  • Storage
  • Desktops
  • New Users
Software
  • System Utilities
  • Industry Specific
  • Network Management
  • Photos / Graphics
  • Page Layout
  • VMware
  • Misc
  • Web Development
  • OS
  • CYGWIN
  • Voice Recognition
  • Virtualization
  • Message Queue
  • Quality Assurance
  • Security
  • Firewalls
  • MultiMedia Applications
  • Development
  • Database
  • Office / Productivity
  • Business Management
  • OS/2 Apps
  • Server Software
  • Internet / Email
ITPro
  • OS
  • Storage
  • Encryption
  • Operating Systems Security
  • Apple Hardware
  • Laptops & Notebooks
  • Servers
  • Networking Hardware
  • Peripherals
  • Devices
  • Displays / Monitors
  • WebTrends / Stats
  • Search Engines
  • Firewalls
  • Web Computing
  • WebApplications
  • IDS
  • Vulnerabilities
  • Email Clients
  • File Sharing
  • Spy / Ad Blockers
  • Web Browsers
  • Web Servers
  • Networking
  • Anti-Virus
  • Consulting
  • Chat / IM
  • Anti Spam
Developer
  • Web Servers
  • Web Browsers
  • Game Programming
  • Dev Tools
  • Industry Specific
  • Office / Productivity
  • Database
  • CYGWIN
  • Web Development
  • Search Engines
  • File Sharing
  • WebTrends / Stats
  • Programming
  • Content Management
  • Application Servers
  • Protocols
Storage
  • Removable Backup Media
  • Storage Technology
  • Servers
  • Grid
  • Remote Access
  • Backup / Restore
  • Misc
  • Hard Drives
OS
  • Miscellaneous
  • Security
  • Development
  • Linux
  • VMware
  • MainFrame OS
  • Unix
  • Apple
  • OS / 2
  • AS / 400
  • BeOS
  • Microsoft
  • VMS / OpenVMS
Database
  • Oracle
  • Miscellaneous
  • MySQL
  • Software
  • Sybase
  • Contact Management
  • PostgreSQL
  • Data Manipulation
  • Clarion
  • InterSystems Cache
  • Siebel
  • MUMPS
  • OLAP
  • SQLBase
  • SAS
  • GIS & GPS
  • 4GL
  • Berkeley DB
  • DB2
  • Informix
  • Interbase / Firebird
  • FoxPro
  • Reporting
  • LDAP
  • Filemaker Pro
  • MS SQL Server
  • dBase
  • MS Access
Security
  • Misc
  • Web Browsers
  • Software Firewalls
  • Operating Systems Security
  • File Sharing
  • Spy / Ad Blockers
  • Vulnerabilities
  • WebApplications
  • IDS
  • Anti-Virus
  • Encryption
  • Anti Spam
  • Email Clients
  • VPN
  • Chat / IM
Programming
  • Editors IDEs
  • Installation
  • Handhelds / PDAs
  • Multimedia Programming
  • System / Kernel
  • Automation
  • Algorithms
  • Game
  • Signal Processing
  • Project Management
  • Open Source
  • Database
  • Misc
  • Languages
  • Processor Platforms
  • Theory
Web Development
  • Scripting
  • Blogs
  • Web Servers
  • Software
  • Search Engines
  • Web Graphics
  • Web Services
  • Images
  • Internet Marketing
  • Images and Photos
  • Components
  • Document Imaging
  • Web Languages/Standards
  • Illustration
  • WebApplications
  • Fonts
  • WebTrends / Stats
  • Authoring
  • Digital Camera Software
  • Miscellaneous
Networking
  • Protocols
  • Apple Networking
  • Network Management
  • Message Queue
  • Application Servers
  • Content Management
  • File Servers
  • Email Servers
  • Misc
  • Java Editors & IDEs
  • Wireless
  • Networking Hardware
  • Backup / Restore
  • System Utilities
  • ISPs & Hosting
  • Web Servers
  • Storage Technology
  • Removable Backup Media
  • Servers
  • Web Computing
  • Broadband
  • Grid
  • OS / 2
  • Novell Netware
  • Unix Networking
  • Windows Networking
  • Security
  • Telecommunications
  • Operating Systems
  • Linux Networking
Other
  • Lounge
  • Business Travel
  • Community Support
  • New Net Users
  • Philosophy / Religion
  • Math / Science
  • Miscellaneous
  • URLs
  • Expert Lounge
  • Politics
  • Puzzles / Riddles
  • Automotive
Community Support
  • Suggestions
  • New to EE
  • New Topics
  • CleanUp
  • Announcements
  • General
  • Feedback
  • Input
  • EE Bugs
 
05.10.2008 at 05:04AM PDT, ID: 21538649
1) Use the ASP.NET's TreeView control with ShowCheckboxes set to All and then bind the data to it (easiest is by using the SqlDataSource control).

2) Do you need to check the count on client side (using javascript) or after user clicks a button?
 
05.10.2008 at 05:09AM PDT, ID: 21538662
1) right I know a datasource...how do I build the relationships so that the categories are the parents and the sub categories are the child.

2) it can be a custom validation control. just need to know how to count them all (without looping through them all and incrementing a variable...maybe a rowCount feature?
 
05.10.2008 at 05:29AM PDT, ID: 21538742
1) Check this link for information on how to build a treeview with relationships: http://www.codeproject.com/KB/custom-controls/AutoBindingTreeView.aspx

2) If you want to do it on client side, you will have to loop through all nodes. On server side, you can get the count with the TreeView's CheckedNodes.Count property
Accepted Solution
 
05.29.2008 at 02:47PM PDT, ID: 21673587
right now I have this...

it's not working...Any ideas what I'm doing wrong?


protected void BuildCategoryTree() {
        additems();

      // CatTree.BeginUpdate();

        CatTree.Nodes.Clear();

        foreach (string[] element in alCats) {

            CatTree.Nodes.Add(new TreeNode(element));
            for (int i = 1; i < element.Length; i++) {
                CatTree.Nodes.Add(new TreeNode(element));
            }

        }

     //   CatTree.EndUpdate();
    }

    void additems() {
        string[] cat1 = { "Automotive", "Breaks", "Tires" };
        string[] cat2 = { "Computers", "Install", "Websites" };
        string[] cat3 = { "Housing-Interior", "Painting", "Dry-wall" };
        string[] cat4 = { "Housing-Exterior", "Roofing", "Painting" };

        alCats.Add(cat1);
        alCats.Add(cat2);
        alCats.Add(cat3);
        alCats.Add(cat4);
    }
 
 
20080716-EE-VQP-32 / EE_QW_EXPERT_20070906