problem with filter

0

I have this code, on the search button, the problem is that when I give it to search it works only once, when I give it back to search it no longer searches

protected void btn_Buscar_Click(object sender, EventArgs e)
    {
        try
        {
        SqlConnection SqlCon = new SqlConnection();
        SqlCon.ConnectionString = Conexion.Cn; // Abre la conexión desde la clase Conexión
        SqlCon.Open();


        // CÓDIGO PARA FILTRO
        SqlDataAdapter da = new SqlDataAdapter("select * from T_Material_Desecho where NombreHerramientaMaterial like '" + txt_Buscar.Text + "%'", SqlCon);
        SqlDataAdapter da2 = new SqlDataAdapter("select * from T_Material_Desecho where Descripcion like '"+txt_Buscar.Text+"%'", SqlCon);
        DataTable dt = new DataTable();

        Gv_Desecho.DataSourceID = "";

        da.Fill(dt);
        da2.Fill(dt);
        this.Gv_Desecho.DataSource = dt;


            //FIN CÓDIGO FILTRO

            //CERRAR CONEXIÓN
            SqlCon.Close();

        }
        catch (Exception)
        {
            Page.ClientScript.RegisterStartupScript(this.GetType(),"scripts","<script>alert('Se produjo un error')</script>");
        }


    }
    
asked by Manuel N 16.11.2018 в 18:40
source

0 answers