Dataview Table.Rows.Count is returning 1 when there is no such rows
asp.net, c#
Solution
The `DataView` references it's original DataTable via the `Table` property. But it does not share the same data. The `DataTable` contains the original data without the applied filter whereas the `DataView` contains only the records after the appplied filter.
You would get the correct count via `DataView.Count`:
int deletedLOVcount = deletedLOV.Count;
MSDN:
Gets the number of records in the DataView after RowFilter and RowStateFilter have been applied.
Problem
consider the code below: ``` DataView deletedLOV = new DataView(tbltmp, "prociLOV_Deleted=1", "prociLOV_ID", DataViewRowState.CurrentRows); DataView addedLOV = new DataView(tbltmp, "prociLOV_Id>1", "prociLOV_ID", DataViewRowState.CurrentRows); int deletedLOVcount=deletedLOV.Table.Rows.Count; int addedLOVcount=addedLOV.Table.Rows.Count; ``` prociLOV_Deleted is set to 1 when a record is deleted. But even when no records are deleted the deletedLOVcount return value 1. Also the same with addedLOVcount when there is no record with proci_ID>1 ,it too returns count as1