Ionutz wrote:
> Hello!
> I derived a control from the standard TreeView control of ASP.NET 2.0, which
> uses custom tree nodes derived from the TreeNode class.
>
> The problem is that when I set the property PopulateOnDemand = true on a
> node of my tree view and try to expand the node, I receive a
> System.NullReferenceException with the folowing stack trace:
>
> at System.Web.UI.WebControls.TreeNode.RenderChildNode s(HtmlTextWriter
> writer, Int32 depth, Boolean[] isLast, Boolean enabled)
> at System.Web.UI.WebControls.TreeView.RaiseCallbackEv ent(String
> eventArgument)
> at
> System.Web.UI.WebControls.TreeView.System.Web.UI.I CallbackEventHandler.RaiseCallbackEvent(String eventArgument)
> at System.Web.UI.Page.ProcessRequestMain(Boolean
> includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
>
>
> When I don't use the populate on demand feature everything works fine.
>
> Here is a snippet of the code that I wrote:
>
> public class MyTreeView : TreeView
> {
> ...
> protected override TreeNode CreateNode()
> {
> return new MyTreeNode();
> }
> ...
> }
>
> public class MyTreeNode : TreeNode
> {
> public MyTreeNode(string text) : base(text)
> {
> }
> }
>
> Also I handled the event TreeNodePopulate to get my nodes data.
>
> Does anyone encountered this problem and is there a workaround for this ?
> I mention that I use VS 2005 beta 2.
>
> Thank you,
Sorry, I don't know the answer to your question, maybe if you use
Reflector and check out the framework code it might give you an idea of
what's going on. On another note, I have a question of my own that
maybe you can answer. I was attempting to override the TreeView and
TreeNode controls so I could alter the nodes render method. I was
trying to add columns. Unfortunately, I discovered that that most of
the methods I needed to override were private. Can I as what you're
doing in your custom controls?
Thanks,
Mark
|