获取UltraWebTree指定节点的所有父节点内容

(继续资源库小程序中UltraWebTree的使用方法,上一篇是利用数据库来填充UltraWebTree
功能要求:当我点击UltraWebTree中子节点时,需要获取该节点所有父节点内容,这样我就能获得该子节点下文件的目录路径了
外加功能:点击节点,其下所有文件显示在UltraWebGrid列表中,其所有目录路径也保存在一个列表中
表结构在文章利用数据库来填充UltraWebTree 中说明了。
UltraWebTree节点点击事件代码:

 1private void UltraWebTree1_NodeClicked(object sender, Infragistics.WebUI.UltraWebNavigator.WebTreeNodeEventArgs e)
 2  {
 3   DataTable dnodechild = Query.ProcessSql("SELECT fname FROM files where fcid='"+ int.Parse(e.Node.DataKey.ToString()) + "'",GlobalVar.DBName); 
 4      DataColumn roothide = new DataColumn("RootText");
 5   //
 6   string nodetext="";
 7   Infragistics.WebUI.UltraWebNavigator.Node node = e.Node; 
 8   do
 9   {
10    nodetext =  node.Text +"\\"+ nodetext;
11    node = node.Parent; 
12   }

13   while (node != null);
14   roothide.DefaultValue = nodetext;
15   //
16   dnodechild.Columns.Add(roothide);
17   this.UltraWebGrid1.Dispose();
18   this.UltraWebGrid1.DataSource = dnodechild;
19   this.UltraWebGrid1.DataBind();
20   dnodechild.Dispose();
21  }

Query.ProcessSql 是用了听棠的SPL持久层,GlobalVar.DBName是数据名
用到了Infragistics另一个UltraWebGrid控件,UltraWebGrid控件中有2列,分别是RootText,fname。

posted @ 2006-05-17 13:28  zjy  阅读(1864)  评论(2编辑  收藏  举报