private void btnConsultar_Click(object sender, EventArgs e) { // Dictionary: Representa una colección de claves y valores. Dictionary <string, object> parametros = new Dictionary <string, object>(); if (!string.IsNullOrEmpty(txtIdProducto.Text)) { var idProducto = txtIdProducto.Text; parametros.Add("id_producto", idProducto); } if (!string.IsNullOrEmpty(txtNombre.Text)) { var nombre = txtNombre.Text; parametros.Add("nombre", nombre); } IList <Producto> listadoPlanes = productoService.ConsultarProductoConFiltros(parametros); dgvProducto.DataSource = listadoPlanes; if (dgvProducto.Rows.Count == 0) { MessageBox.Show("No se encontraron coincidencias para el/los filtros ingresados", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Information); } }