RELATEED CONSULTING
相关咨询
选择下列产品马上在线沟通
服务时间:9:30-18:00
你可能遇到了下面的问题
关闭右侧工具栏
用dataset来填充tree
  • 作者:xiaoxiao
  • 发表时间:2020-12-23 10:53
  • 来源:未知

1,<iewc:TreeView id=TreeView1 style="Z-INDEX: 101; LEFT: 152px; POSITION: absolute; TOP: 168px" TreeNodeSrc="categories.aspx" runat="server">

2,categories.aspx.cs

private void Page_Load(object sender, System.EventArgs e)  {   string sql=@"select categoryname as Text,'products.aspx?catid='+ltrim(str(categoryid)) as TreeNodesrc     from categories as TreeNode for xml auto ,xmlData " ;   SqlConnection sqlConn=new SqlConnection("Server=dbm-1;Uid=sa;pwd=;DataBase=Northwind");   SqlCommand  com=new  SqlCommand (sql,sqlConn);   DataSet ds=new DataSet();   sqlConn .Open();    ds.ReadXml(com.ExecuteXmlReader(),XmlReadMode.Fragment );   sqlConn.Close();   sqlConn=null;

   ds.DataSetName ="TREENODES";   ds.WriteXml(Response.OutputStream );

  }