I am populating a datagridview with objects like this:
foreach (NavField field in this.Fields)
{
DataGridViewColumn column = new DataGridViewColumn();
column.HeaderText = field.Caption;
column.Name = field.FieldNo.ToString();
column.ValueType = field.GetFieldType();
column.CellTemplate = new DataGridViewTextBoxCell();
grid.Columns.Add(column);
}
int count = 0;
foreach (NavRecord record in this.Records)
{
grid.Rows.Add();
foreach (NavItem item in record.items)
{
//Adding the rows
grid.Rows[count].Cells[item.FieldNo.ToString()].Value = item.RecordValue;
}
count++;
}
But the datasource of the grid stays null. Is there any other solution to populate the grid, or update the datasource?