Good afternoon, I'm filling a GridView, but when I'm going to perform the filter, it tells me the following error: "Object reference not set to an instance of an object." The field I'm trying to filter, expiration, is of type date, and I use SQL. I have tried in many ways, with # between dates, setting, but without the same error.
I tried this way:
ds.Tables["cantas_apagar"].DefaultView.RowFilter = String.Format(CultureInfo.InvariantCulture.DateTimeFormat, "vencimento >= # {0} #", txtDataInicial.Text) + "and" + String.Format(CultureInfo.InvariantCulture.DateTimeFormat, "vencimento <= # {0} #", txtDataInicial.Text);
GridView1.DataBind();
So:
ds.Tables["cantas_apagar"].DefaultView.RowFilter = "(vencimento >= #" + txtDataInicial.Text + " # and vencimento <= #" + txtDataFinal.Text + "#)";
GridView1.DataBind();
If anyone has any ideas, thank you. Thank you.