Value of DropDownLIst to object

0

Hello community, I'm jeff, new to this community, I have a query: I have a dropdownlist that I load with an enum and then I want to create an object

  Particular c = new Particular(documentoparticular, TipoDelCliente, nombreparticular, apellidoparticular, telefonoparticular, AnoClienteparticular, PaisDelCliente);

where CustomerDype wants to pass the value of DropDownList1 to the object How is it done?

Particular c = new Particular(documentoparticular,Cliente.EnumTipoCliente.Particular, nombreparticular, apellidoparticular, telefonoparticular, AnoClienteparticular, PaisDelCliente);

If I do it in the following way it works: Customer.EnumCustomerType.Particular Can you make the drop down list option send it in the constructor?

  public Particular(string documento,EnumTipoCliente tipo , string nombre, string apellido, string untelefono, int unAnoIngreso,EnumPais pais)
    {
        this.Documento = documento;
        this.Tipo = tipo;
        this.Nombre = nombre;
        this.Apellido = apellido;
        this.Telefono = untelefono;
        this.AnoIngreso = unAnoIngreso;
        this.pais = pais;
    }
    
asked by Jeff Fernando 02.03.2018 в 21:09
source

1 answer

1

try this:

        Particular c = new Particular(documentoparticular, (EnumTipoCliente)dropdownlist1.SelectedValue, nombreparticular, apellidoparticular, telefonoparticular, AnoClienteparticular, PaisDelCliente);

the dropdownlist would have to contain a property that returns the selected value, try to convert it to the type of the enumeration and pass it as an argument.

    
answered by 06.03.2018 в 20:55