Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The first thing I'm going to say is that I know that this way is not "answering" your question about creating a custom checkbox, but rather is giving you what I consider a better way to handle with this kind of situations. When we are handling with CRUD views, sometimes our business objects don't have the necessary information that the views need, or in cases they have much more than we need. So I recommend using ViewModels.</p> <p>The viewModel would be something like this (I'm just putting the first property, Mascara, and assume that your object is called Form):</p> <pre><code>public class FormViewModel() { public int MascaraCant { get; set; } public Boolean MascaraBueno { get; set; } public Boolean MascaraRegular { get; set; } public Boolean MascaraDeficiente { get; set; } public string MascaraObservaciones { get; set; } } </code></pre> <p>That's the object your controller is going to send from the get method to the view, and then receive in the post method from the view. Your controller would be something like this.</p> <pre><code>public class FormController: Controller { public ActionResult Create() { return View(new FormViewModel()); } [HttpPost] public ActionResult Create(FormViewModel model) { var form = new Form(); //Properties that no need any logic to be mapped form.MascaraCant= model.MascaraCant; form.MascaraObservaciones = model.MascaraObservaciones; //This is where I put the logic to be mapped if(model.MascaraBueno) form.EstadoDeLaPieza = "Bueno"; else if(model.MascaraRegular) form.EstadoDeLaPieza = "Regular"; else if(model.MascaraDeficiente) form.EstadoDeLaPieza = "Deficiente"; Save(form); return View(new FormViewModel()); } } </code></pre> <p>So as you can see, all I do is to use a different object to communicate my controllers with the view, so I can play with the different tools needed in each views. Could be available data from a list, like Cities, countries, etc. </p> <p>For the properties that no need a logic to be mapped like MascaraCant I would recommend you a <a href="http://www.nuget.org/packages/AutoMapper/" rel="nofollow">nugget package called AutoMapper</a></p> <p>Hope it helped. </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload