Ondemand TreeView populating of derived class is failed on second OnPopulate event
<p>I found the problem with PopulateOnDemand with my treview class derived from System.Web.UI TreeView.</p>

<p>I made my </p>

<pre><code> public class ParishTV : System.Web.UI.WebControls.TreeView
</code></pre>

<p>and also my TreeNode</p>

<pre><code>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;
    }
}
</code></pre>

<p>I assemble em in standalone dll and include in my project.
Also I downloaded adapters in source codes from <a href="http://www.asp.net/CSSAdapters/" rel="nofollow">http://www.asp.net/CSSAdapters/</a> 
added there adapter for ParishTV.</p>

<p>I registered </p>

<pre><code>&lt;%@ Register TagPrefix="Pari" Namespace="ParishNS" Assembly="ParishTV" %&gt;
</code></pre>

<p>and create tree</p>

<p>

<p>I fill tree within OnInit eventhandler from DB. </p>

<p>Ah, also I made record for attaching adapter to my tree class:</p>

<pre><code>  &lt;adapter controlType="System.Web.UI.WebControls.TreeView" adapterType="CSSFriendly.TreeViewAdapter" /&gt;
  &lt;adapter controlType="ParishNS.ParishTV"  adapterType="CSSFriendly.ParishTVAdapter" /&gt;
</code></pre>

<p>Well, everything works fine When I do Not use populate on demand.</p>

<p>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 </p>

<pre><code>        &lt;Nodes&gt;
            &lt;Pari:ParishTVNode Text="Inventory1" Value="1"  Expanded ="false" SelectAction="Expand" PopulateOnDemand="true" /&gt;
            &lt;Pari:ParishTVNode Text="Inventory2" Value="2" Expanded ="false" SelectAction="Expand" PopulateOnDemand="true" /&gt;
            &lt;Pari:ParishTVNode Text="Inventory3" Value="3" Expanded ="false" SelectAction="Expand"  PopulateOnDemand="true" /&gt;
        &lt;/Nodes&gt;
</code></pre>

<p>When OnPopulate occurs I create MY ParishTVNode:</p>

<pre><code>    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);
</code></pre>

<p>...</p>

<p>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 ^^. </p>

<p>All new nodes from second OnPopulate firing are TreeNodes but not ParishTVNodes.</p>

<p>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. </p>

<p>Help, please.</p>
