M
michael sorens
I have been trying to figure out how to use DataSets, BindingSources,
DataGridViews, and XML together, but it is a challenge. I understand how
to populate a DataGridView with XML basically as:
DataSet ds = new DataSet();
ds.ReadXml(@"\usr\tmp\sample.xml");
dataGridView.DataSource = ds;
dataGridView.DataMember = "targetElement";
What I found through experimentation is that the DataMember may specify
any element in the XML, and the DataGridView will then display any of its
children that are text nodes.
Question 1: Is there a code sample that emulates the hierarchical behavior
handled by the older DataGrid component? I understand that a single
DataGridView cannot do this, but I am sure someone must have modeled it
with two DataGridViews.
Question 2: In my DataGridView, the XML elements that I want to display as
columns are at different hierarchical levels. What is the "best practice"
for building a custom DataSet?
Question 3 (extending question 2): How would I also included new, computed
columns based on other fields in the XML?
--------------------
For those interested, here are some useful references I have uncovered in
my explorations of this topic:
DataGrid vs DataGrid View
http://msdn2.microsoft.com/en-us/library/ms171628.aspx
Binding XML to a DataGridView
http://msdn.microsoft.com/library/d...con/html/vbwlkWalkthroughAccessingXMLData.asp
Binding Objects to a DataGridView
http://www.codeproject.com/useritems/datagridview.asp
Binding to a DataGrid
http://www.codeproject.com/soap/AgConfig.asp
DataGridViews, and XML together, but it is a challenge. I understand how
to populate a DataGridView with XML basically as:
DataSet ds = new DataSet();
ds.ReadXml(@"\usr\tmp\sample.xml");
dataGridView.DataSource = ds;
dataGridView.DataMember = "targetElement";
What I found through experimentation is that the DataMember may specify
any element in the XML, and the DataGridView will then display any of its
children that are text nodes.
Question 1: Is there a code sample that emulates the hierarchical behavior
handled by the older DataGrid component? I understand that a single
DataGridView cannot do this, but I am sure someone must have modeled it
with two DataGridViews.
Question 2: In my DataGridView, the XML elements that I want to display as
columns are at different hierarchical levels. What is the "best practice"
for building a custom DataSet?
Question 3 (extending question 2): How would I also included new, computed
columns based on other fields in the XML?
--------------------
For those interested, here are some useful references I have uncovered in
my explorations of this topic:
DataGrid vs DataGrid View
http://msdn2.microsoft.com/en-us/library/ms171628.aspx
Binding XML to a DataGridView
http://msdn.microsoft.com/library/d...con/html/vbwlkWalkthroughAccessingXMLData.asp
Binding Objects to a DataGridView
http://www.codeproject.com/useritems/datagridview.asp
Binding to a DataGrid
http://www.codeproject.com/soap/AgConfig.asp