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 501313
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T06:10:36+00:00 2026-05-13T06:10:36+00:00

I found the problem with PopulateOnDemand with my treview class derived from System.Web.UI TreeView.

  • 0

I found the problem with PopulateOnDemand with my treview class derived from System.Web.UI TreeView.

I made my

 public class ParishTV : System.Web.UI.WebControls.TreeView

and also my TreeNode

public class ParishTVNode : TreeNode
{
    public DateTime LastLoaded;

    public ParishTVNode():base()
    {

    }
    public ParishTVNode(string text, string value, string ImageURL, string navigateURL, string target): base(text, value, ImageURL, navigateURL, target)
    {
        LastLoaded = DateTime.Now;
    }
    public ParishTVNode(string s)
        : base(s)
    {
        LastLoaded = DateTime.Now;
    }
}

I assemble em in standalone dll and include in my project.
Also I downloaded adapters in source codes from http://www.asp.net/CSSAdapters/
added there adapter for ParishTV.

I registered

<%@ Register TagPrefix="Pari" Namespace="ParishNS" Assembly="ParishTV" %>

and create tree

I fill tree within OnInit eventhandler from DB.

Ah, also I made record for attaching adapter to my tree class:

  <adapter controlType="System.Web.UI.WebControls.TreeView" adapterType="CSSFriendly.TreeViewAdapter" />
  <adapter controlType="ParishNS.ParishTV"  adapterType="CSSFriendly.ParishTVAdapter" />

Well, everything works fine When I do Not use populate on demand.

First problem occurs when I realised that OnInit in faired each time I click on node and tree is rebuild from scratch. okey, I removed OnInit and populate Tree with some nodes from aspx file useing

        <Nodes>
            <Pari:ParishTVNode Text="Inventory1" Value="1"  Expanded ="false" SelectAction="Expand" PopulateOnDemand="true" />
            <Pari:ParishTVNode Text="Inventory2" Value="2" Expanded ="false" SelectAction="Expand" PopulateOnDemand="true" />
            <Pari:ParishTVNode Text="Inventory3" Value="3" Expanded ="false" SelectAction="Expand"  PopulateOnDemand="true" />
        </Nodes>

When OnPopulate occurs I create MY ParishTVNode:

    TreeNode child = null;
    switch (e.Node.Value)
    {
        case "1":
            child = new ParishTVNode("Classical");
            e.Node.ChildNodes.Add(child);

            child = new ParishTVNode("Rock");

            e.Node.ChildNodes.Add(child);

…

It works! but only once. when one node is populated it is ok, but then depending not on what node is populated somehow are created nodes with Correct text and correct values, but Not of My parishTVNode type but of Base TreeNode class ^^.

All new nodes from second OnPopulate firing are TreeNodes but not ParishTVNodes.

I create ParisTVNodes, and at the end of OnPopulate eventhandler they are ParishTVNodes, but when Adapter is trying to render em, first nodes are ParishTVNodes and these bad nodes are TreeNodes.

Help, please.

  • 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-13T06:10:37+00:00Added an answer on May 13, 2026 at 6:10 am

    You need to override the CreateNode method. On postback, the TreeView has to reconstruct the tree from the viewstate. This method allows treeview extenders to use their own TreeNode types without experiencing the issue you’re dealing with.

    Its pretty simple to do…

    override TreeNode CreateNode()
    {
      return new ParishTVNode();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I found a problem with the XML Serialization of C#. The output of the
I have found a problem with use JQuery timeout, i have a page with
problem euler #5 i found the solution but i don't know why this first
A problem I ran into a while back I never found a good solution
Maybe someone found a workaround for the following problem: It seems as if AXIS
In trying to solve the ajax back button problem I have found the Really
How do I let Microsoft know about a problem I've found in one of
I've been struggling with a problem for the past couple days and haven't found
Here is a hum-dinger of a problem that I have not found an answer
I was trying to solve my XNA Font problem , when I found this

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.