Good morning Devexpress staff
I had bene trying to set a filter for first gridview load without success
I am trying to set a date filte after the first load, using the next code[VB.NET]
grdPuestos.DataSource = dtPuestos grdPuestos.KeyFieldName = "EMST_ID" If primera_carga = 1 Then grdPuestos.FilterExpression = "[FECHA_INICIO] = '" & dia & "/" & mes & "/" & ano & "'" grdPuestos.PageIndex = 0 grdPuestos.DataBind() grdPuestos.BeginUpdate() grdPuestos.EndUpdate()
Why is not working properly?
there is a field name FECHA_INICIO I can asure that
<dx:BootstrapGridViewDateColumn FieldName="FECHA_INICIO" Caption="F. inicio" HorizontalAlign="center" />
I researched this issue and found its cause.
The filter expression should be specified in a special format described in the Criteria Language Syntax article.
In addition, since you want to use strict equality, you should take into account the fact that the data can contain not only the date, but also the time.
In this case, I recommend that you use our Criteria Operators.
Dim day As Integer = 6 Dim mounth As Integer = 10 Dim year As Integer = 2019 Dim date = New DateTime(year, mounth, day) Dim startOperator = New BinaryOperator("_Date", date, BinaryOperatorType.GreaterOrEqual) Dim endOperator = New BinaryOperator("_Date", date.AddDays(1), BinaryOperatorType.Less) grdPuestos.FilterExpression = New GroupOperator(GroupOperatorType.And, startOperator, endOperator).ToString() grdPuestos.DataBind()
Please try this approach and let me know your results.