Infralution Support Forum Index Infralution Support
Support groups for Infralution products
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Bind hierarchical XML like 'ADO.NET Dataset Browser' example

 
Post new topic   Reply to topic    Infralution Support Forum Index -> Virtual Tree Support
View previous topic :: View next topic  
Author Message
Robertico



Joined: 12 Apr 2010
Posts: 7

PostPosted: Mon Apr 12, 2010 5:21 pm    Post subject: Bind hierarchical XML like 'ADO.NET Dataset Browser' example Reply with quote

Is it possible to parse a hierarchical XML file and bind it to Virtual Tree, like the 'ADO.NET Dataset Browser' example.

Sample code is appreciated - (VS2008 - C#)
Back to top
View user's profile Send private message
Infralution



Joined: 28 Feb 2005
Posts: 5027

PostPosted: Mon Apr 12, 2010 11:30 pm    Post subject: Reply with quote

Yes - ADO.NET Datasets support reading data from hierarchical XML. So you can simply read the data into a dataset and then bind to the dataset. See this MSDN article on reading XML data into Datasets:

http://msdn.microsoft.com/en-us/library/fx29c3yd(VS.71).aspx

If you create a Dataset upfront using the dataset designer that matches your XML schema then you can bind to the dataset at design time (just like the ADO.NET Dataset Browser sample). If you use the DataSet.ReadXml methods ability to dynamically create the Dataset (based on an inferred schema) then you will need to create the Virtual Tree bindings at runtime.
_________________
Infralution Support
Back to top
View user's profile Send private message Visit poster's website
Robertico



Joined: 12 Apr 2010
Posts: 7

PostPosted: Tue Apr 13, 2010 4:02 pm    Post subject: Reply with quote

Thanks for the explanation. I'm going to try.
_________________
There are only 10 types of people in the world: Those who understand binary, and those who don't
Back to top
View user's profile Send private message
Robertico



Joined: 12 Apr 2010
Posts: 7

PostPosted: Fri Apr 16, 2010 7:25 am    Post subject: Reply with quote

I use the DataSet.ReadXml methods ability. I do not understand how create the Virtual Tree bindings at runtime.
_________________
There are only 10 types of people in the world: Those who understand binary, and those who don't
Back to top
View user's profile Send private message
Infralution



Joined: 28 Feb 2005
Posts: 5027

PostPosted: Fri Apr 16, 2010 8:11 am    Post subject: Reply with quote

Actually if your schema is fixed (ie you know what the table and column names will be) then you can just create the bindings in the designer as described in the help section "Data Binding to ADO.NET Datasets and DataViews".

If you do want or need to create the bindings programmatically then you need to do something like the following example which would bind Virtual Tree to the customer table in the DataSet sample project:

Code:
// add a binding for the root item (the DataView/Table)
//
DataViewRowBinding viewBinding = new DataViewRowBinding();
_virtualTree.RowBindings.Add(viewBinding);

// add a binding for rows from the table
//
DataRowRowBinding customerRowBinding = new DataRowRowBinding();
customerRowBinding.Table = "Customers";
customerRowBinding.Icon = Properties.Resources.CustomerIcon;
_virtualTree.RowBindings.Add(customerRowBinding);

// add cell bindings that bind fields from the row to particular Virtual Tree columns
//
customerRowBinding.CellBindings.Add(new DataRowCellBinding(colMain, "CompanyName"));
customerRowBinding.CellBindings.Add(new DataRowCellBinding(colAddress, "Address"));

_________________
Infralution Support
Back to top
View user's profile Send private message Visit poster's website
Robertico



Joined: 12 Apr 2010
Posts: 7

PostPosted: Sat Apr 17, 2010 11:31 am    Post subject: Reply with quote

It worked.

Many thanks !
_________________
There are only 10 types of people in the world: Those who understand binary, and those who don't
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Infralution Support Forum Index -> Virtual Tree Support All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group