1
Good afternoon, I am filled a Gridview, but when I am going to perform the filter, it informs me the following error "Object reference not set for an instance of an object." The field I’m trying to filter, expire, is date type, and I use SQL. I have tried several ways, with # between dates, configuring, but without the same error occurs.
I tried so:
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();
Thus:
ds.Tables["cantas_apagar"].DefaultView.RowFilter = "(vencimento >= #" + txtDataInicial.Text + " # and vencimento <= #" + txtDataFinal.Text + "#)";
GridView1.DataBind();
If anyone has any ideas, thank you. Thank you.