Treeview and rendercontrol

Discussion in 'ASP .Net Building Controls' started by David Wiart, Sep 20, 2006.

  1. David Wiart

    David Wiart Guest

    Hi,

    I try to get the html code of the treeview by doing this :

    TreeView Tview = new TreeView();
    TreeNode tnode = new TreeNode("Node1", "1");
    Tview.Nodes.Add(tnode);
    Tview.ID = "Tree1";
    System.IO.StringWriter tw = new System.IO.StringWriter();
    System.Web.UI.HtmlTextWriter hw = new System.Web.UI.HtmlTextWriter(tw);
    Tview.RenderControl(hw);

    But I get the following exception and I found no solution for the
    moment, please help !!

    -----------------------------------------------------------------------------------------------------------------------------------
    System.NullReferenceException was unhandled by user code
    Message="Object reference not set to an instance of an object."
    Source="System.Web"
    StackTrace:
    at System.Web.UI.Control.get_SpacerImageUrl()
    at
    System.Web.UI.WebControls.TreeView.RenderBeginTag( HtmlTextWriter
    writer)
    at System.Web.UI.WebControls.WebControl.Render(HtmlTe xtWriter
    writer)
    at System.Web.UI.Control.RenderControlInternal(HtmlTe xtWriter
    writer, ControlAdapter adapter)
    at System.Web.UI.Control.RenderControl(HtmlTextWriter writer,
    ControlAdapter adapter)
    at System.Web.UI.Control.RenderControl(HtmlTextWriter writer)
    at WebControlLibrary1.MyControl.RenderContents(HtmlTe xtWriter
    output) in C:\Work\WebSite1\WebControlLibrary1\MyControl.cs:l ine 27
    at System.Web.UI.WebControls.WebControl.Render(HtmlTe xtWriter
    writer)
    at System.Web.UI.Control.RenderControlInternal(HtmlTe xtWriter
    writer, ControlAdapter adapter)
    at System.Web.UI.Control.RenderControl(HtmlTextWriter writer,
    ControlAdapter adapter)
    at System.Web.UI.Control.RenderControl(HtmlTextWriter writer)
    at System.Web.UI.Control.RenderChildrenInternal(HtmlT extWriter
    writer, ICollection children)
    at System.Web.UI.Control.RenderChildren(HtmlTextWrite r writer)
    at
    System.Web.UI.HtmlControls.HtmlForm.RenderChildren (HtmlTextWriter
    writer)
    at
    System.Web.UI.HtmlControls.HtmlContainerControl.Re nder(HtmlTextWriter
    writer)
    at System.Web.UI.HtmlControls.HtmlForm.Render(HtmlTex tWriter
    output)
    at System.Web.UI.Control.RenderControlInternal(HtmlTe xtWriter
    writer, ControlAdapter adapter)
    at System.Web.UI.Control.RenderControl(HtmlTextWriter writer,
    ControlAdapter adapter)
    at System.Web.UI.Control.RenderControl(HtmlTextWriter writer)
    at
    System.Web.UI.HtmlControls.HtmlForm.RenderControl( HtmlTextWriter
    writer)
    at System.Web.UI.Control.RenderChildrenInternal(HtmlT extWriter
    writer, ICollection children)
    at System.Web.UI.Control.RenderChildren(HtmlTextWrite r writer)
    at System.Web.UI.Control.Render(HtmlTextWriter writer)
    at System.Web.UI.Page.Render(HtmlTextWriter writer)
    at System.Web.UI.Control.RenderControlInternal(HtmlTe xtWriter
    writer, ControlAdapter adapter)
    at System.Web.UI.Control.RenderControl(HtmlTextWriter writer,
    ControlAdapter adapter)
    at System.Web.UI.Control.RenderControl(HtmlTextWriter writer)
    at System.Web.UI.Page.ProcessRequestMain(Boolean
    includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
    David Wiart, Sep 20, 2006
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    0
    Views:
    1,048
  2. Replies:
    0
    Views:
    1,108
  3. GroupReader

    RenderControl and asp:TreeView

    GroupReader, Mar 29, 2007, in forum: ASP .Net
    Replies:
    1
    Views:
    511
    bruce barker
    Mar 29, 2007
  4. Prakash V

    Treeview RenderControl Error

    Prakash V, Jun 7, 2006, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    218
    Prakash V
    Jun 7, 2006
  5. GroupReader

    RenderControl and TreeView

    GroupReader, Mar 29, 2007, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    151
    GroupReader
    Mar 29, 2007
Loading...

Share This Page