Ejemplo n.º 1
0
        protected void BuscarButton_Click(object sender, EventArgs e)
        {
            Cuentas   Cuenta = new Cuentas();
            DataTable dt     = new DataTable();
            string    filtro = "1=1";

            if (FiltroDropDown.SelectedIndex == 0) //CuentaId
            {
                if (FiltroTextBox.Text.Trim().Length == 0)
                {
                    filtro = "1=1";
                }
                else
                {
                    filtro = "CuentaId = " + FiltroTextBox.Text;
                }
            }
            else if (FiltroDropDown.SelectedIndex == 1) //Descripcion
            {
                if (FiltroTextBox.Text.Trim().Length == 0)
                {
                    filtro = "1=1";
                }
                else
                {
                    filtro = "Descripcion like '%" + FiltroTextBox.Text + "%'";
                }
            }
            else if (FiltroDropDown.SelectedIndex == 2) //Balance
            {
                if (FiltroTextBox.Text.Trim().Length == 0)
                {
                    filtro = "1=1";
                }
                else
                {
                    filtro = "Balance = " + FiltroTextBox.Text;
                }
            }

            dt = Cuenta.Listar("CuentaId, Descripcion, Balance", filtro);
            BuscarGridView.DataSource = dt;
            BuscarGridView.DataBind();
        }