Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

149
Vistas
Dropdown list return always default value 0

I have problem. When i didn't search something in dropdown It has got default selected value=0. And its saving my database. If it can send value"NULL" not will save in my database. How can i send default value "NULL"?

  <div class="form-group">
        <label class="control-label col-md-2"></label>
        <div class="col-md-8">
            @*@Html.DropDownList("CustomerID", null, new { @class = "form-control", required = "required", placeholder = "Müşteri Seçiniz" })*@
            @Html.DropDownList("CustomerID", Enumerable.Empty<SelectListItem>(), "", new { @multiple = "multiple", @id = "CustomerID", @class = "form-control" })
            @Html.ValidationMessageFor(model => model.CustomerID, "", new { @class = "text-danger", style="color:red"})
            <p style="color:red;margin-bottom:-3px" id="errorpersonel"></p>
        </div>
    </div>
<script language="javascript" type="text/javascript">

$(document).ready(function () {
    debugger;
    $("#CustomerID").pqSelect({
        singlePlaceholder: '', width: '92%'
    });

    $.ajax({

        url: "/TicketDashboard/GetCustomer",
        method: "Post",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function (data) {


            $("#CustomerID").empty();

            $.each(data, function (index, value) {
                debugger;

                $('#CustomerID').append('<option value="' + value.CustomerID + '">' + value.CustomerName + '</option>');

            });

            $("#CustomerID").pqSelect("refreshData");

            $('span[data-valmsg-for="OpportunityAttachmentViewModel.CCMail"]').html('Boş geçilemez.');
        }
    });
});

$("#CustomerID").pqSelect({
    singlePlaceholder: '',
    multiplePlaceholder: 'Müşteri Seçiniz',
    maxSelect: 1,
}).on("change", function (evt) {



    pccmail = $(this).val();

    if (pccmail != "") {
        $('span[data-valmsg-for="OpportunityAttachmentViewModel.CCMail"]').html('');



    } else {
        $('span[data-valmsg-for="OpportunityAttachmentViewModel.CCMail"]').html('Boş geçilemez');
    }
    $('[id^=CCMailinput]').val(pccmail);
});

Its my codes. How can i change selected value "0"? It should be "NULL" when i sent form

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You can choose a null value as below if the selected value is 0.

pccmail = $(this).val()=="0"?null:(this).val();

  <div class="form-group">
        <label class="control-label col-md-2"></label>
        <div class="col-md-8">
            @*@Html.DropDownList("CustomerID", null, new { @class = "form-control", required = "required", placeholder = "Müşteri Seçiniz" })*@
            @Html.DropDownList("CustomerID", Enumerable.Empty<SelectListItem>(), "", new { @multiple = "multiple", @id = "CustomerID", @class = "form-control" })
            @Html.ValidationMessageFor(model => model.CustomerID, "", new { @class = "text-danger", style="color:red"})
            <p style="color:red;margin-bottom:-3px" id="errorpersonel"></p>
        </div>
    </div>
<script language="javascript" type="text/javascript">

$(document).ready(function () {
    debugger;
    $("#CustomerID").pqSelect({
        singlePlaceholder: '', width: '92%'
    });

    $.ajax({

        url: "/TicketDashboard/GetCustomer",
        method: "Post",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function (data) {


            $("#CustomerID").empty();

            $.each(data, function (index, value) {
                debugger;

                $('#CustomerID').append('<option value="' + value.CustomerID + '">' + value.CustomerName + '</option>');

            });

            $("#CustomerID").pqSelect("refreshData");

            $('span[data-valmsg-for="OpportunityAttachmentViewModel.CCMail"]').html('Boş geçilemez.');
        }
    });
});

$("#CustomerID").pqSelect({
    singlePlaceholder: '',
    multiplePlaceholder: 'Müşteri Seçiniz',
    maxSelect: 1,
}).on("change", function (evt) {



    pccmail = $(this).val()=="0"?null:(this).val();

    if (pccmail != "") {
        $('span[data-valmsg-for="OpportunityAttachmentViewModel.CCMail"]').html('');



    } else {
        $('span[data-valmsg-for="OpportunityAttachmentViewModel.CCMail"]').html('Boş geçilemez');
    }
    $('[id^=CCMailinput]').val(pccmail);
});
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda