Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
395
Adding Root Node After Databinding
posted

Hi,

 I need to add a root node to the treeview after databinding it to a datatable. Is this possible??  (Something similar we do for a dropdownlist, like inserting a blank option after datainding with the ddl.insert(0, "Please choose"))

basically, I need to have a hardcoded root node in the treeview.

Parents
No Data
Reply
  • 28464
    posted

    Yes, I can see where this is indeed convenient. Actually, we need a property like AppendDataBoundNodes, to persist what is currently available in the treeview prior to databinding - this way it would be much easier to just add one root node and proceed with databinding from there.

    In any case, I believe the easiest solution in this case would be to create one additional DataTable in your DataSet (I assume you are using several related DataTables inside a DataSet) - this DataTable will only hold one item that is root.

    An alternative approach would be to clone nodes from one tree to another - first bind a treeview and then use cloning to populare another: There is some sample code for this here:

    http://forums.infragistics.com/forums/t/1731.aspx

    Hope this helps. 

Children
No Data