DataGridView does not display the data from XML file
Hi there everyone.
As the titles says, I'm trying to load data into a datagridview from an xml file and the datagridview just doesn't show up any data at all. I've ran the debug to check if the variables and references were working right and it looks to me that the variables are working and recognizing the data on the xml file.
Here's my code:
Code:
Dim yourXmlFileWithFullPath As String = "PortalUNI429.xml"
Dim newDataSet As DataSet = New DataSet("New DataSet")
newDataSet.ReadXml(yourXmlFileWithFullPath)
bsDeliverySites.DataSource = newDataSet
dgDeliverySites.DataSource = bsDeliverySites
dgDeliverySites.DataMember = "Order"
Note: bsDeliverySites is the name of the BindingSource component and dgDeliverySites is the name of the DataGridView component.
I can't post the XML file here, because it's part of the company I'm working at and it has a lot of sensitive information, but I can trully assure everyone that the xml file is 100% correctly coded, as it's being used for a few operations... although I can say that the node after root node is "Order" (this will explain the value of the DataMember field)
Does anyone know what am I missing here?
Re: DataGridView does not display the data from XML file
You're filling newDataSet from the xml file and setting the DataGridView's DataSource to bsDeliverySites.
Edit: Missed the not on bsDeliverySites being the BindingSource.
Put a breakpoint after you've filled your DataSet and see if you've got any data in it. Do you have a DataTable called Order in the DataSet?
Re: DataGridView does not display the data from XML file
bsDeliverySites.DataSource = newDataSet
dgDeliverySites.DataSource = bsDeliverySites
A DGV requires a datatable as its datasource. It cannot handle a DataSet even if there's only one table present. And .... dgDeliverySites.DataMember = "Order" ... doesn't solve that problem either. Also bsDeliverySites is completely redundant. This is all you need ...
dgDeliverySites.DataSource = newDataSet.Tables(0)
Re: DataGridView does not display the data from XML file
Thanks for the replies guys, I've found out the problem. I did have everything correct, the problem was that the DGV doesn't show any data on nodes that don't have any text lol.......
Well, this now leads me to a huge head ache... because I need to get blocks of data that I need to edit later on and I need the DGV to show thos blocks of data (i.e. specific tables)...