I have created a filter on a datagridview that gets fired by the user typing into a number of textboxes.
So for example the fields to filter on are DocID, BatchID etc
All works fine unless there is a Null value in one of the cells. If this is the case the Null values are not shown. If a user types BatchID = 200 I need all records to show for BatchID if DocID is Null or not.
I somehow need to exclude the DocID Filter line from the filter when you the user has not typed something in there.
This is my code that is not working right:
BindingSource.Filter =
"CONVERT(BatchID, System.String) Like" & "'" & txtfBatchID.Text & "%" & "'" _
& "AND DocID Like" & "'" & txtfDocID.Text & "%" & "OR DocID Is Null " & "'"
So for example the fields to filter on are DocID, BatchID etc
All works fine unless there is a Null value in one of the cells. If this is the case the Null values are not shown. If a user types BatchID = 200 I need all records to show for BatchID if DocID is Null or not.
I somehow need to exclude the DocID Filter line from the filter when you the user has not typed something in there.
This is my code that is not working right:
BindingSource.Filter =
"CONVERT(BatchID, System.String) Like" & "'" & txtfBatchID.Text & "%" & "'" _
& "AND DocID Like" & "'" & txtfDocID.Text & "%" & "OR DocID Is Null " & "'"