问题描述
这很好用。但是,树在输出中没有崩溃。它扩展了所有节点。命名空间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没有崩溃。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!