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
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.
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