binding dataset to DataGridView

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
 
R

RobinS

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

Robin S.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top