Welcome Guest Search | Active Topics | Sign In | Register

CallBackPanel has failed Error when a TreeView loads too many records Options
Scott
Posted: Friday, November 20, 2009 11:27:08 AM
Rank: Newbie
Groups: Member

Joined: 10/13/2007
Posts: 8
Hello,

I have created a simple Callback panel and added a TreeView that loads data from a database.

The code below is an example that fails only when the callback is initiated by the user when selecting the button to trigger the control and not at the pageload. In this example I am trying to make it fail, but when I apply this code to my dataset, the number of records "Customers" --> orders, bills, etc. fails at as little as 10 customers.

What's interesting is when I remove the callback panel from the equation, then the code and the Treeview work fine and I can load over 100 customers.

Can you please help me resolve my issues?

Code: HTML/ASPX
<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="TreeCallBackTest.aspx.vb" Inherits="WebSite.TreeCallBackTest" %>

<%@ Register Assembly="EO.Web" Namespace="EO.Web" TagPrefix="eo" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <eo:CallbackPanel ID="CallbackPanel1" runat="server" Height="150px" Triggers="{ControlID:Button1;Parameter:}" Width="200px">
            <eo:TreeView ID="SR" runat="server" AutoSelectSource="ItemClick" ControlSkinID="None" Height="250px" Width="200px">
                <LookNodes>
                    <eo:TreeNode DisabledStyle-CssText="background-color:transparent;border-bottom-style:none;border-left-style:none;border-right-style:none;border-top-style:none;color:Gray;padding-bottom:1px;padding-left:1px;padding-right:1px;padding-top:1px;" ItemID="_Default" NormalStyle-CssText="PADDING-RIGHT: 1px; PADDING-LEFT: 1px; PADDING-BOTTOM: 1px; COLOR: black; BORDER-TOP-STYLE: none; PADDING-TOP: 1px; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: transparent; BORDER-BOTTOM-STYLE: none" SelectedStyle-CssText="background-color:#316ac5;border-bottom-color:#999999;border-bottom-style:solid;border-bottom-width:1px;border-left-color:#999999;border-left-style:solid;border-left-width:1px;border-right-color:#999999;border-right-style:solid;border-right-width:1px;border-top-color:#999999;border-top-style:solid;border-top-width:1px;color:White;padding-bottom:0px;padding-left:0px;padding-right:0px;padding-top:0px;">
                    </eo:TreeNode>
                </LookNodes>
                <TopGroup Style-CssText="border-bottom-color:#999999;border-bottom-style:solid;border-bottom-width:1px;border-left-color:#999999;border-left-style:solid;border-left-width:1px;border-right-color:#999999;border-right-style:solid;border-right-width:1px;border-top-color:#999999;border-top-style:solid;border-top-width:1px;color:black;cursor:hand;font-family:Tahoma;font-size:8pt;padding-bottom:2px;padding-left:2px;padding-right:2px;padding-top:2px;">
                </TopGroup>
            </eo:TreeView>
        </eo:CallbackPanel>
         </div>
        <asp:Button ID="Button1" runat="server" Text="Button" />
    </form>
</body>
</html>


Code: Visual Basic.NET
Partial Public Class TreeCallBackTest
    Inherits System.Web.UI.Page
    Protected Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not IsPostBack Then
            LoadTree(30)
        End If
    End Sub
    
    Protected Sub LoadTree(ByVal NumberofRecords As Integer)

        Dim str As String = String.Empty
        Dim CustomerNode As EO.Web.TreeNode
        Dim OrderNode As EO.Web.TreeNode
        Dim level3Node As New EO.Web.TreeNode
        Dim level4Node As New EO.Web.TreeNode


        SR.Nodes.Clear()
        Dim NodeID As Integer = -1

        For i As Integer = 0 To NumberofRecords
            'Add Customer to tree
            NodeID += 1
            CustomerNode = New EO.Web.TreeNode
            CustomerNode.Text = "Customer " & i
            CustomerNode.Value = "Customer_ID"
            CustomerNode.ItemID = NodeID
            CustomerNode.Selected = True
            CustomerNode.NormalStyle.BackColor = Drawing.Color.LightYellow

            For j As Integer = 0 To 10
                'Add order information
                NodeID += 1
                OrderNode = New EO.Web.TreeNode
                OrderNode.Text = "Order: Test"
                OrderNode.Value = "Order_ID"
                OrderNode.ItemID = NodeID

                For k As Integer = 0 To 10
                    NodeID += 1
                    level3Node = New EO.Web.TreeNode

                    level3Node.Text = "Bill"
                    level3Node.Value = "Billing_ID"
                    level3Node.ItemID = NodeID
                    level3Node.NormalStyle.BackColor = Drawing.Color.LightGreen

                    For L As Integer = 0 To 10

                        NodeID += 1
                        level4Node = New EO.Web.TreeNode
                        level4Node.Text = "Machine"
                        level4Node.Value = "Task_ID," & L
                        level4Node.ItemID = NodeID
                        level4Node.NormalStyle.BackColor = Drawing.Color.LightPink

                        level3Node.SubGroup.Nodes.Add(level4Node)
                    Next
                    OrderNode.SubGroup.Nodes.Add(level3Node)
                Next

                CustomerNode.SubGroup.Nodes.Add(OrderNode)

            Next

            SR.Nodes.Add(CustomerNode)
        Next




    End Sub

    Protected Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        LoadTree(25)
    End Sub


End Class
eo_support
Posted: Friday, November 20, 2009 2:43:59 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
Hi,

This definitely won't work. You have about 10,000 nodes. You should try to avoid such scenario even without using CallbackPanel. Using a CallbackPanel will make the situation worse for several reasons. One reason is the page takes too long to load, so there is a good chance that user will try to trigger the CallbackPanel before the page finishes loading; Another reason is when the CallbackPanel runs, it will also take a long time because it has to collect status information from all these nodes.

The best solution for such scenario is to use populate on demand. That way the child nodes will only be created when user expand them. A typical example of such scenario is MS's online MSDN library. There is no way to have all the topic nodes all created and it doesn't make sense to create them all either --- nobody will visit all the nodes anyway.

Thanks!


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.