Search code examples
vb.netdatagridviewdataviewrowfilter

DataView RowFilter not working properly, not considering the first row of table


There is a datagridview that is mapped with the table m_dtProperty. In this table there is RowChecked column with value either 0 or -1.

I have to select all rows with rowChecked value -1. I applied a row filter. It is not returning the 1st row of the table. For example: m_dtProperty Table

:RowChecked :Value:
..................
:  -1       :  A :
:  -1       :  B :
:  -1       :  C :
:  -1       :  D :

When i applied the row filter, Its returning the

:RowChecked :Value:
..................
:  -1       :  B :
:  -1       :  C :
:  -1       :  D :

Its not returning the fist row.

 Dim objDataView As New DataView(m_dtProperty)
 objDataView.RowFilter() = "RowChecked=" & "-1"
 Dim objNewTable As DataTable = objDataView.ToTable("Save", False, "Value")

Solution

  • I have some troubles with RowFilter, hence finding your query.
    Perhaps check that the source table does not have delete flags set for Row 1. ie call Table.AcceptChanges() before creating the DataView.
    - Also add a space to the end of RowFilter string - Ensure column 1 is a number type (it probably is, but just wanted to add this as it is often cause of problems)