Rashmi S Rashmi S - 21 days ago 11
C# Question

Convert dataRowview to dataTable in c#

I am trying to convert dataRowview into Datatable:

private void Cell_Edit_End(object sender, DataGridCellEditEndingEventArgs e)
{
DataRowView rowView = e.Row.Item as DataRowView;
rowBeingEdited = rowView;
}
DataTable dt = new DataTable();
foreach (DataRow row in rowBeingEdited.Row.GetChildRows) {
dt.ImportRow(row);
}


Can anyone help me to solve.

Answer

We can directly convert dataRowview into Datatable as:

 DataTable dt = rowBeingEdited.DataView.ToTable();
Comments