Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > Treeview RenderControl Error

Reply
Thread Tools

Treeview RenderControl Error

 
 
Prakash V
Guest
Posts: n/a
 
      06-07-2006
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(HtmlTe xtWriter writer) +31
System.Web.UI.Control.RenderControlInternal(HtmlTe xtWriter 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.Cal lback(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


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
TreeView control postback on click of plus sign when rendered using RenderControl vikasparihar Software 1 07-09-2010 07:48 PM
RenderControl and asp:TreeView GroupReader ASP .Net 1 03-29-2007 10:42 PM
TreeView in Custom User Control RenderControl error apenly@gmail.com ASP .Net 0 11-07-2006 06:37 PM
Treeview and rendercontrol David Wiart ASP .Net Building Controls 0 09-20-2006 08:44 AM
TreeView in 2.0 and RenderControl zoneboy@gmail.com ASP .Net 0 08-25-2005 12:31 PM



Advertisments