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?
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;
...
}
You can cast like:
datarow= DirectCast (System.Data.DataRowView, System.Data.DataRow).row
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With