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. 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,065
  2. Replies:
    0
    Views:
    1,156
  3. GroupReader

    RenderControl and asp:TreeView

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

    Treeview and rendercontrol

    David Wiart, Sep 20, 2006, in forum: ASP .Net Building Controls
    Replies:
    0
    Views:
    233
    David Wiart
    Sep 20, 2006
  5. LanceM
    Replies:
    0
    Views:
    259
    LanceM
    Dec 1, 2006
Loading...

Share This Page