本文介绍了Treeview没有崩溃。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这很好用。但是,树在输出中没有崩溃。它扩展了所有节点。



命名空间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();

使用(SqlConnection connection = new SqlConnection(connectionstring))

{



SqlCommand Selectcommand = new SqlCommand(queryString,connection);

connection.Open();

XmlReader xr = Selectcommand.ExecuteXmlReader();

xr.MoveToContent ();

xml = xr.ReadOuterXml();

TreeView1.CollapseAll();

}



返回xml;









}



}



}





请帮我

解决方案


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

解决方案


这篇关于Treeview没有崩溃。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-21 12:28