3
Answers

How do i add the return table to the DataGridView

petre ricardo

petre ricardo

15y
3k
1

Hi,
I haev created a Data Grid view control at design and add three columns at design time one includes a check box.
Then at the buton clicck event:
 
private
void btnLoad_Click(object sender, EventArgs e)
{
ds = DBConn.GetAllReocrds();
int i = 0;
foreach (DataRow item in ds.Tables[0].Rows)
{
dgvMulti.Rows[i].Cells[0].Value = item[0];
i++;
}
}

"DBConn" object of class DBConnection that has the method GetAllReocrds() that returns a Dataset that has a three columned table.
What i was trying to do is to load each cell value of the retuned table to the cells of the dgvMulti... unforntuately "dgvMulti.Rows[i].Cells[0]" thorws an error. the cells werre created. How do i fix this and add data to the dgvMulti?
TY
Answers (3)