TB.TreeGrid [英] TB.TreeGrid

查看:89
本文介绍了TB.TreeGrid的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何将数据绑定到TB.Treegrid.在以下代码中的tg.databind处引发错误.请帮忙





How to bind data to TB.Treegrid. Throws an error at tg.databind in the below code. Please help





TreeGrid tg = new TreeGrid();

DataTable ItemTable = new DataTable("MyTable");
ItemTable.Columns.Add("FunctionID", typeof(int));
ItemTable.Columns.Add("ParentID", typeof(int));
ItemTable.Columns.Add("FunctionName", typeof(String)); // add some test data

ItemTable.Rows.Add(new object[] { 0,-1, "Bill Gates"    });
ItemTable.Rows.Add(new object[] { 1, 0, "Steve Ballmer" });
ItemTable.Rows.Add(new object[] { 3, 1, "Mary Smith"    });
ItemTable.Rows.Add(new object[] { 2, 0, "Paul Allen"    });
ItemTable.Rows.Add(new object[] { 4, 2, "Ahmed Jones"   });
ItemTable.Rows.Add(new object[] { 5, 2, "Wing Lee"      });

DataRow[] SortedRows;
SortedRows = ItemTable.Select("", "ParentID");

XmlDocument XDoc = new XmlDocument();
XmlDeclaration XDec = XDoc.CreateXmlDeclaration("1.0", null, null);
XDoc.AppendChild(XDec);
foreach (DataRow Row in SortedRows)
{

    XmlElement NewNode = XDoc.CreateElement("_" + Row["FunctionID"].ToString());
    NewNode.SetAttribute("FunctionID", Row["FunctionID"].ToString());
    NewNode.SetAttribute("ParentID", Row["ParentID"].ToString());
    NewNode.SetAttribute("FunctionName", Row["FunctionName"].ToString());

    if ((int)Row["ParentID"] == -1)
    {
           XDoc.AppendChild(NewNode);  // root node

          
     }
     else
     {
            String SearchString;
            SearchString = String.Format("//*[@FunctionID=\"{0}\"] ", Row["ParentID"].ToString());
            XmlNode Parent = XDoc.SelectSingleNode(SearchString);
            if (Parent != null)
                Parent.AppendChild(NewNode);
      }
     }

XmlDataSource XDdataSource = new XmlDataSource();
XDdataSource.ID = DateTime.Now.Ticks.ToString();  // unique ID is required
XDdataSource.Data = XDoc.OuterXml;


tg.DataSource = XDdataSource;
tg.DataBind();



[修改:只是将其向下移动,以便代码可以更好地填充屏幕并固定代码中的选项卡.]



[Modified: just moved it down so that the code could fill the screen better and fixed the tabs in the code.]

推荐答案

很遗憾,这是一个自定义控件,因此该论坛中任何人使用此控件的可能性都非常低.

我建议您回到文章( TB.TreeGrid [ http://treegrid.codeplex.com/ [
其下的第一项是DataSource的DataBind.

因此,除非进行了更新,否则似乎尚未对其进行编程.
Unfortunately, this is a custom built control, so the likelihood of anyone in this forum having used this control is pretty low.

I would suggest going back to the article (TB.TreeGrid[^]) and asking this in the forum at the bottom of that page.

And when you do, you really need to specify which error it is throwing. Because what error it is will determine the course of action to take.

[Just found this]

If you go to the page for the source code (http://treegrid.codeplex.com/[^]), you''ll notice a section on that page called "Future Work"

The first item under it is DataBind from DataSource.

So, unless that''s been updated, it would look like that hasn''t been programmed into it yet.


我收到一条错误消息未设置对象实例",基本上是空引用错误.

令我惊讶的是,在下载演示时,它清楚地表明它支持数据绑定,当我尝试与普通数据集绑定时,它说需要分层数据集.因此,我建立了层次数据集.现在,当传递XMLDatasource时,我看到了一个问题.所以...可能需要在这里做些什么
I get an error "Object instance not set" basically a nullreference error.

What I am surprised is while downloading the demo it clearly said it supports databind and when I tried binding with the normal dataset, it says hierarchical dataset is required. So I built the hierachical dataset. Now when passing the XMLDatasource, I see there is a problem. So... probably there is something needs to be done here


这篇关于TB.TreeGrid的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆