Change the default value of a Boolean in an ASP.NET select

Asked

Viewed 51 times

1

I have a field on my system that needs to inform if the product is available or not, SQL is as bit( TRUE or FALSE).

Entityframework generated a View with a SELECT True or False.

inserir a descrição da imagem aqui

<div class="form-group">
    @Html.LabelFor(model => model.Alugada, htmlAttributes: new { @class = "control-label col-md-2" })
    <div class="col-md-10">
        <div class="checkbox">
            @Html.EditorFor(model => model.Alugada)
            @Html.ValidationMessageFor(model => model.ativa, "", new { @class = "text-danger" })
        </div>
    </div>
</div>

How I customize the True and False fields?

  • Would you have access to creating this form on the front? If you have you can check the select option, I will post a reply with my example, but the form is generated by me, I do not know if it is possible

1 answer

0

I created a form and added the same fields for testing, hope it works.

At the time of starting the form I put so that it creates a string list and add as datasource of the list.

    protected void Page_Load(object sender, EventArgs e)
    {
        List<string> situacao = new List<string>();
        situacao.Add("Ativo");
        situacao.Add("Inativo");
        lstSituacao.DataSource = situacao;
        lstSituacao.DataBind();
    }

inserir a descrição da imagem aqui

Then when sending to the bank you make the validation and exchange, that would be on the button.

If you have access to BACK of the form and FRONT I could but has only one of them.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.