Click here to Skip to main content
15,908,175 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
hi, this works good. but, tree is not collapsing in output. it expand all node.

namespace xmltreeview
{
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
TreeView1.CollapseAll();
XmlDataSource1.Data = GetHierarchicalDataFromSqlServer();

}
string GetHierarchicalDataFromSqlServer()
{

string xml = string.Empty;


string queryString = @" sqlquery";
string connectionstring = ConfigurationManager.ConnectionStrings["sqlconnectstring"].ToString();
using(SqlConnection connection=new SqlConnection(connectionstring))
{

SqlCommand Selectcommand = new SqlCommand(queryString, connection);
connection.Open();
XmlReader xr = Selectcommand.ExecuteXmlReader();
xr.MoveToContent();
xml = xr.ReadOuterXml();
TreeView1.CollapseAll();
}

return xml;




}

}

}


pls help me
Posted
Comments
Syed Shabeer 1-Aug-13 1:36am    
Try collapseAll method in PreRender event. Let me know if it works.

1 solution

 
Share this answer
 
Comments
christhuxavier 1-Aug-13 2:46am    
hi i did with prerender. but it is not working

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900