like loading a combobox from sqlserver achievement that you can add null values

0

Well, please help me in this problem, I will put the code: This is the stored procedure

ALTER procedure [dbo].[uspListarMarcaXEstado]
@estado int
as
select idmarca,marca,e.manteniento  from Marca m inner join Estado e 
on m.idestado=e.idestado
where e.idestado=@estado

This is in the Data layer

 public DataTable ListarproductoxEstado(Producto pro)
        {
            daPro = new SqlDataAdapter("uspListarProductoxEstado", cn.abrirConexion());
            daPro.SelectCommand.CommandType = CommandType.StoredProcedure;
            daPro.SelectCommand.Parameters.AddWithValue("@estado", pro.estado.idestado);
            dtPro = new DataTable();
            daPro.Fill(dtPro);
            return dtPro;

        }

Well in the Business layer I just call the method

And in the Presentation Layer

  public void cargarMarca()
        {
            Marca mar = new Marca();

            Estado es = new Estado();
            es.idestado = 1;
            mar.estado = es;

            cbomarca.DataSource = marne.ListadoMarcaxEstado(mar);
            cbomarca.DisplayMember = "marca";

            cbomarca.ValueMember = "idmarca";


        }

Well, what I want to achieve is that at the moment of inserting a Product, I have the option that the mark that is a Combo can be empty, that is to say Null .

Marca mar = new Marca();
mar.idmarca = int.Parse(cbomarca.SelectedValue.ToString());
pro.marca = mar;
    
asked by CRISTHIAN MIGUEL GONZALES RUBI 21.07.2018 в 05:35
source

0 answers