binding dataset to DataGridView

  • Thread starter Thread starter bill
  • Start date Start date
B

bill

All,

I have the following:


BindingSource bs = new BindingSource();
private void initDataGridView(DataGridView dgv)
{


// dsForDGV is a datset object on the form


dsForDGV.Tables[0].Rows.Add("abc");


bs.DataSource = dsForDGV;
bs.DataMember = dsForDGV.Tables[0].TableName;
dgv.DataSource = bs;


dgv.Refresh();
}


Nothing appears in the DataGridView. What am I missing?


TIA,


Bill
 
Maybe you need to do an EndEdit after the Rows.Add
to update the dataset that is bound to the grid.

Robin S.
 
Back
Top