DataBinding: ‘System.Data.DataRowView’ does not contain a property with the name when using ImportRow(row)
issue: when try to bind or access the data colum from the datatable (from ImportRow method)
DataTable dTable = datatablesource //sql fetch
DataTable dTableFilter = new DataTable();
for (int i = 0; i < dTable.Rows.Count; ++i)
{
dTableFilter.ImportRow(dTable.Rows[i]);
}
//then
for (int i = 0; i < dTableFilter.Rows.Count; i++)
{
lblRet.Text += "
" + dTableFilter.Rows[i]["columnname"].ToString(); // produce following error
}
error: DataBinding: ‘System.Data.DataRowView’ does not contain a property with the name “columname”
solution: make sure you clone the structure of the schema of the old datatable
e.g. before the importrow for loop
put: dTableFilter = dTable.Clone(); // clone the structure & schema
No trackbacks yet.