Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3224062
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T16:10:45+00:00 2026-05-17T16:10:45+00:00

How can I bind data to YUI Treeview control http://developer.yahoo.com/yui/examples/treeview/default_tree.html here is sample JavaScript

  • 0

How can I bind data to YUI Treeview control http://developer.yahoo.com/yui/examples/treeview/default_tree.html

here is sample JavaScript code that have been used in the above URL

<div id="treeDiv1">
</div>

<script type="text/javascript">
    var tree;
    (function() {
        function treeInit() {
            buildRandomTextNodeTree();
        }
        function buildRandomTextNodeTree() {
            tree = new YAHOO.widget.TreeView("treeDiv1");
            for (var i = 0; i < 5; i++) {
                var tmpNode = new YAHOO.widget.TextNode("label-" + i, tree.getRoot(), false);
                buildLargeBranch(tmpNode);
            }
            tree.draw();
        }
        function buildLargeBranch(node) {
            if (node.depth < 8) {
                YAHOO.log("buildRandomTextBranch: " + node.index, "info", "example");
                for (var i = 0; i < 8; i++) {
                    new YAHOO.widget.TextNode(node.label + "-" + i, node, false);
                }
            }
        }

        YAHOO.util.Event.onDOMReady(treeInit);
    })();

</script>

The problem is, YUI treeview control is binded in javascript, but I want to bind in C# code, because I need to get data from Database, here is how I am binding data to asp.net treeview control

if (dsSalesRepresent.Tables[0].Rows.Count > 0)
    {
        dsSalesRepresent.Relations.Add("Children", dsSalesRepresent.Tables[0].Columns["NodeId"], dsSalesRepresent.Tables[0].Columns["ParentId"]);

        trvSalesRepresent.Nodes.Clear();

        foreach (DataRow masterRow in dsSalesRepresent.Tables[0].Rows)
        {
            if (masterRow["ParentId"].ToString() == "")
            {
                TreeNode masterNode = new TreeNode((String)masterRow["JobTitle"], Convert.ToString(masterRow["NodeId"]));
                trvSalesRepresent.Nodes.Add(masterNode);

                TreeNode FirstchildNode = new TreeNode((String)masterRow["UserName"], Convert.ToString(masterRow["ParentId"]));
                masterNode.ChildNodes.Add(FirstchildNode);

                foreach (DataRow childRow in masterRow.GetChildRows("Children"))
                {
                    TreeNode childNode = new TreeNode((String)childRow["UserName"], Convert.ToString(childRow["ParentId"]));
                    masterNode.ChildNodes.Add(childNode);
                }
            }
        }
        trvSalesRepresent.ExpandAll();
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T16:10:46+00:00Added an answer on May 17, 2026 at 4:10 pm

    All of my comments are assuming you mean WebForms and not MVC.

    The YUI framework is purely client side. It is intended to be able to used with any website regardless of the server platform. The ASP.NET tree view is used only with ASP.Net and so doesn’t have that limitation. It is a server control and so it actually emits everything the client needs even though it looks like you are binding directly to it.

    A couple of options, but there’s lots:

    • Use an AJAX/JSON to call back to your website to get the data in JSON format which you can then handle client side.

    Just the way that you’re asking this question makes me think that you aren’t that familiar with “real” AJAX, so that’s why I’ve got the next option:

    • Emit the Java YUI code directly from your code behind. Javascript is just more text that the server sends to the client and you can dynamically emit it just like any other part of your client script. ScriptManager can help here as far as getting it to the right spot on the page, but you could theoretically do it with just a place holder or literal control. Alternately, you could put most of the code in the markup and use <% %> to replace the parts that need to come from the server side. Either way, you need to write all the code to render your tree, then figure out the “Replaceable” bits and supply them from the server side code. BUT make sure that none of the info coming back is data that was entered by an end user otherwise you could end up with a Cross Site Scripting vulnerability.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How can I bind data to a System.Web.UI.WebControls.Table - control? and, How can I
Any idea how one can bind binary data to a ComponentOne WebReport control?
I have a user control where the XAML of the control can bind to
How can i Bind data in Accordian in C# .net
How can I bind arguments to a Python function so that I can call
With ASP.NET 3.5 I can easily bind to an XML file by using an
I'm building an application in C# using WPF. How can I bind to some
i'm trying to create a ObjectDataSource which I can use to bind to a
I have a scenario where I don't really know how to bind data to
Can somebody point me to a resource that explains how to go about having

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.