The following two code snippets populate a BindingSource which is later assigned to a DataGridView.DataSource.
When the concrete class QuotesTool.LineItem is used (first snippet) the grid DOES NOT display the appropriate data:
BindingSource lineList = new BindingSource();
foreach (XElement y in _lines.Elements())
{
lineList.Add(new QuotesTool.LineItem(
y.Element("Vendor").Value,
y.Element("Model").Value,
y.Element("Selling_Unit").Value,
y.Element("Net_Price").Value,
y.Element("Spec").Value
));
}
But, if an anonymous type is used the grid displays data OK:
foreach (XElement y in _lines.Elements())
{
lineList.Add(
new {
vendor = y.Element("Vendor").Value,
Model = y.Element("Model").Value,
UOM = y.Element("Selling_Unit").Value,
Price = y.Element("Net_Price").Value,
Description = y.Element("Spec").Value
});
}
Any ideas would be appreciated. Thanks.