Treeview RenderControl Error

Discussion in 'ASP .Net Web Controls' started by Prakash V, Jun 7, 2006.

  1. Prakash V

    Prakash V Guest

    Hi all,

    i am trying to render a treeview control and send the HTML output
    to some other method, but it gives NullReferenceException, i tried many ways
    but could not solve this issue. if i add the control directly to page it
    works but gives error while using RenderControl.
    my code & stack trace

    private string RenderTree()
    {
    TreeView Tview = new TreeView();
    TreeNode tnode = new TreeNode("Node1", "1");
    Tview.Nodes.Add(tnode);
    Tview.ID = "Tree1";
    StringBuilder sb = new StringBuilder();
    StringWriter sw = new StringWriter(sb);
    HtmlTextWriter htmlTW = new HtmlTextWriter(sw);
    Tview.RenderControl(htmlTW);
    return sb.ToString();
    }

    [NullReferenceException: Object reference not set to an instance of an
    object.]
    System.Web.UI.Control.get_SpacerImageUrl() +50
    System.Web.UI.WebControls.TreeView.RenderBeginTag(HtmlTextWriter writer)
    +202
    System.Web.UI.WebControls.WebControl.Render(HtmlTextWriter writer) +31
    System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer,
    ControlAdapter adapter) +74
    System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter
    adapter) +291
    System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +49
    TreeviewRender.RenderTree() in
    d:\TestProject\TestProject\TreeviewRender.aspx.cs:30
    TreeviewRender.Page_Load(Object sender, EventArgs e) in
    d:\TestProject\TestProject\TreeviewRender.aspx.cs:17
    System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o,
    Object t, EventArgs e) +31
    System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender,
    EventArgs e) +68
    System.Web.UI.Control.OnLoad(EventArgs e) +88
    System.Web.UI.Control.LoadRecursive() +74
    System.Web.UI.Page.ProcessRequestMain(Boolean
    includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3030


    Thanks in Advance,
    Prakash.V
     
    Prakash V, Jun 7, 2006
    #1
    1. Advertisements

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. George Ter-Saakov

    Render vs RenderControl

    George Ter-Saakov, Nov 10, 2003, in forum: ASP .Net
    Replies:
    3
    Views:
    20,486
    sobin
    Oct 25, 2006
  2. Steve Chatham

    Datagrid to Excel - error - rendercontrol

    Steve Chatham, Feb 23, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    564
    Steve Chatham
    Feb 23, 2004
  3. Replies:
    0
    Views:
    1,122
  4. Replies:
    0
    Views:
    1,347
  5. GroupReader

    RenderControl and asp:TreeView

    GroupReader, Mar 29, 2007, in forum: ASP .Net
    Replies:
    1
    Views:
    610
    bruce barker
    Mar 29, 2007
  6. David Wiart

    Treeview and rendercontrol

    David Wiart, Sep 20, 2006, in forum: ASP .Net Building Controls
    Replies:
    0
    Views:
    319
    David Wiart
    Sep 20, 2006
  7. LanceM
    Replies:
    0
    Views:
    323
    LanceM
    Dec 1, 2006
  8. GroupReader

    RenderControl and TreeView

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