I am using the following code to fill a datagridview with rows from a datatable.
private void FillEmpEmer()
{
int emerNo;
empEmerDT.Columns.Add("Emergency Number", typeof(string));
empEmerDT.Columns.Add("Emergency Address", typeof(string));
empEmerRows = EmpInfoDS.Tables["EmpEmer"].Select("EmpID='" + txt_EmpID.Text + "'");
foreach (DataRow dR in empEmerRows)
{
emerNo = Convert.ToInt32(dR[1]);
emerRows = EmpInfoDS.Tables["Emer"].Select("EmerNo='" + emerNo + "'");
empEmerDT.Rows.Add(emerNo, emerRows[0][1]);
}
dataGrid_Emer.DataSource = null;
dataGrid_Emer.DataSource = empEmerDT.DefaultView;
}
How do I store the new Rows that have been added to the datagridview into a new DATAROW array ???
You can take advantage of DataTable’s GetChanges method to get a reference to the DataRows that has been added.
It’s like this: