I'm using a textbox to filter some money values but instead of getting me all the fields of gridview it refreshes the webpage. I want to only filter values from gridview where I can only filter values > 0. How can I fix my problem here?
protected void Button3_Click(object sender, EventArgs e)
{
//Filter data using textbox//
string filter = "";
string command = "SELECT * FROM NaoMatch WHERE Cliente is not null And";
if (TextPesquisarDataMovimento.Text != "")
{
filter = filter + " [Data Movimento ] LIKE '%" + TextPesquisarDataMovimento.Text + "%' AND";
Debug.Write(filter);
}
if (TextPesquisarDataValor.Text != "")
{
filter = filter + " [Data Valor] LIKE '%" + TextPesquisarDataValor.Text + "%' AND";
Debug.Write(filter);
}
if (TextPesquisarDescricao.Text != "")
{
filter = filter + " [Descricao] LIKE '%" + TextPesquisarDescricao.Text + "%' AND";
Debug.Write(filter);
}
if (TextPesquisarCliente.Text != "")
{
filter = filter + " [Cliente] LIKE '%" + TextPesquisarCliente.Text + "%' AND";
Debug.Write(filter);
}
if (textValorcIva.Text != "")
{
filter = filter + " Valor > 0 LIKE '%" + textValorcIva.Text + "%' AND";
Debug.Write(filter);
}
if (filter.Length > 0)
{
Sqldata.DataSource = SqlDataSource1;
string FinalFilter = filter.Remove(filter.Length - 3);
SqlDataSource1.SelectCommand = command + FinalFilter;
Sqldata.DataBind();
}
else
{
Sqldata.DataBind();
}
}