ASP.NET - Rendering problem in Treeview Control

Asked By Kumar K M on 29-Jan-10 03:27 AM
Hi,

I am using Asp tree view control.when i add more than 1000 records i'm getting rendering problems.Is there any other way to improve the tree view performance.I don't want to use any third party control.Is there any free third party control available.But if you tell me how to improve the performance in asp tree view itself means it will be better.because i have used that for my whole object.this is a bug which i got in the last minute.please do help me.

thanks,
kumar
Sreekumar P replied to Kumar K M on 29-Jan-10 03:45 AM
its better for u to use any javascript TreeeView controls.
eg: http://www.dynamicdrive.com/dynamicindex1/treeview/index.htm
http://be.twixt.us/jquery/treeView.php

create that controls from the server side when pageload or create a usercontrol

If u r not able to create those in serverside plz feel free to contact me.

thank u
Sreekumar P replied to Kumar K M on 29-Jan-10 03:53 AM
http://jquery.bassistance.de/treeview/demo/
Huggy Bear replied to Kumar K M on 29-Jan-10 04:59 AM
Since you say 1000 rows, firstly I would question you whether the datasource of the TreeView, say a datatable is being stored in ViewState, if so remove it and use session instead. Because the ViewState data would finally endup in sitting on your browser.
Also it would be better if you provide the exact issue or error message that you are getting.
Kumar K M replied to Huggy Bear on 29-Jan-10 06:10 AM
i'm not using any datasource.it has to be added dynamically
Kumar K M replied to Huggy Bear on 30-Jan-10 01:43 AM
Hi,
 Thanks for your reply.Actually when i try to add 1000 records at time it's taking more than 2 mins to load dynamically and what i think to override the render method of the treeview control. Another problem is when i try to refresh the tree.it's state is lost.I want to use session to maintain the state of the tree.is it possible.tell me how please.
Huggy Bear replied to Kumar K M on 01-Feb-10 12:41 AM
I don't think that you can improve the performance of the TreeView control by overriding Render event. I would rather looking at decreasing the content of the TreeView by using Html control in the template columns and avoid the usage of any images and things like that.

Using Session:

I order to maintain your datasource, say a datatable in Session follow the below code

//Check if the session object is null and populate the object from DB
if(Session["treeview_datasource"] == null)
{
//Query the database and populate the session object.
}
//Fetch the datatable from session always.
DataTable dt = Session["treeview_datasource"] as DataTable;

//Set the datasource and do the bind
TreeView1.DataSource = dt;
TreeView1.DataBind();

Note: In order to mantain the session you can use InProc, StateServer or Sql. If you are using a loadbalancer then it is wise to use StateServer