Unable to cast object of type 'System.Data.DataRowView' to type 'System.Data.DataRow'

c#

Solution

A `DataRowView` is not a `DataRow`, and isn't convertible to a `DataRow`. However, you can access the corresponding `DataRow` using the `Row` property :

foreach(DataRowView drv in dataView)
{
    DataRow row = drv.Row;
    ...
}

Problem

I have following exception in the foreach loop Unable to cast object of type 'System.Data.DataRowView' to type 'System.Data.DataRow' How to solve the issue?

Original source