This is a migrated thread and some comments may be shown as answers.

TreeView not working

2 Answers 105 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Tonyz289
Top achievements
Rank 1
Tonyz289 asked on 30 Aug 2011, 06:39 PM
I am going crazy. I had tree view and it worked, now it doesn't. So I isolated to code from the TreeView onto a page by itself and it still doesn't work.

Here is the code for the page;
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="lp.aspx.cs" Inherits="lp" %>
 
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<head runat="server">
    <title></title>
    <telerik:RadStyleSheetManager ID="RadStyleSheetManager1" runat="server" />
    <script type="text/javascript" src="lpScript.js"></script>
</head>
<body>
    <form id="form1" runat="server">
    <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
        <Scripts>
            <%--Needed for JavaScript IntelliSense in VS2010--%>
            <%--For VS2008 replace RadScriptManager with ScriptManager--%>
            <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.Core.js" />
            <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQuery.js" />
            <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQueryInclude.js" />
        </Scripts>
    </telerik:RadScriptManager>
    <script type="text/javascript">
        //Put your JavaScript code here.
    </script>
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" ClientEvents-OnResponseEnd="ClientResponseEnd">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="Panel1">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="Panel1" />
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManager>
    <div>
        <telerik:RadTreeView ID="RadTreeView1" runat="server" CheckBoxes="True" MultipleSelect="True"
            ShowLineImages="False" EnableEmbeddedSkins="False" TriStateCheckBoxes="False">
            <NodeTemplate>
                <asp:Label ID="lblnodeText" Text='<%#Eval("title") %>' runat="server" />
                <asp:Label ID="lblCatId" Text='<%#Eval("Id") %>' runat="server" Visible="false"></asp:Label>
                <asp:Label ID="lblisCustomer" Text='<%#Eval("isCustomer") %>' runat="server" Visible="false"></asp:Label>
                <asp:Label ID="Description" runat="server" Text='<%#Eval("description") %>' />
            </NodeTemplate>
        </telerik:RadTreeView>
    </div>
    </form>
</body>
</html>
Here is the code behind.
using System;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using System.Data;
using System.Configuration;
using System.Collections.Generic;
using System.Web.Security;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Telerik.Web.UI;

public partial class lp : System.Web.UI.Page
{
    protected void Page_Load (object sender, EventArgs e)
    {
        bindAssetTree ();
    }
    private void bindAssetTree ()
    {
        List<AssetTree> ds = getAssetTree (User.Identity.Name);
        RadTreeView1.DataSource = ds;
        RadTreeView1.DataFieldID = "Id";
        RadTreeView1.DataFieldParentID = "IdParent";
        RadTreeView1.DataTextField = "Title";
        RadTreeView1.DataValueField = "Id";
        RadTreeView1.DataBind ();
    }
    public class AssetTree
    {
        public int id { get; set; }
        public int idParent { get; set; }
        public String title { get; set; }
        public Boolean isCustomer { get; set; }
        public Boolean isUserCreated { get; set; }
        public Boolean allowDelete { get; set; }
        public String description { get; set; }
        public Boolean descriptionVisible { get; set; }

        public AssetTree ()
        {
        }

        public AssetTree (int id, int idParent, String title, Boolean isCustomer, Boolean isUserCreated, Boolean allowDelete, String description, Boolean descriptionVisible)
        {
            this.id = id;
            this.idParent = idParent;
            this.title = title;
            this.isCustomer = isCustomer;
            this.isUserCreated = isUserCreated;
            this.allowDelete = allowDelete;
            this.description = description;
            this.descriptionVisible = descriptionVisible;
        }
    }

    public List<AssetTree> getAssetTree (String username)
    {
        List<AssetTree> at = new List<AssetTree> ();
        for (int i = 0; i < assetTree.Length; i++)
            at.Add (assetTree[i]);

        return at;
    }

    AssetTree[] assetTree = {new AssetTree (2270, -2147483648, "Intuitive", false, false, true, "Intuitive Solutions Tree", false),
                                new AssetTree (2270, -2147483648, "Intuitive Solutions Tree", false, true, false, "Intuitive", false)};
}

2 Answers, 1 is accepted

Sort by
0
Accepted
Plamen
Telerik team
answered on 02 Sep 2011, 02:56 PM
Hi Tonyz289 ,

I tested the code i got an error only for the ClientEvents-OnResponseEnd="ClientResponseEnd" that is not defined.
As for the rest of the page you can consult with this help topic where is explained how exactly this kind of the binding is made.

Hope this is helpful.

All the best,
Plamen Zdravkov
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

0
Tonyz289
Top achievements
Rank 1
answered on 02 Sep 2011, 03:29 PM
Got it.  The example data I used was bogus.
Tags
TreeView
Asked by
Tonyz289
Top achievements
Rank 1
Answers by
Plamen
Telerik team
Tonyz289
Top achievements
Rank 1
Share this question
or