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.
我们可以将dataRowview直接转换为Datatable,如下所示:
DataTable dt = rowBeingEdited.DataView.ToTable();
You can use DataRow.Table.Clone()
to get an empty table with the same columns:
DataRow[] childRows = rowBeingEdited.Row.GetChildRows("RelationName");
if (childRows.Length > 0)
{
DataTable tblChildren = childRows[0].Table.Clone();
foreach (DataRow row in childRows)
tblChildren.ImportRow(row);
}
If there is a filter, this is the right answer
datagridview.DataSource.current.DataView.ToTable()
I tried all the other solution this not orking so well or it takes a long time
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.