jeudi 14 avril 2016

Display checkbox Data value from database using mvc

I need to create a form to register.

the example of form will look like this

enter image description here

how do I display the value in the red circle in the form? (the value is from database)

My controller

namespace Insurance.Controllers
{
public class FlexiPAController : Controller
{
    //
    // GET: /FlexiPA/

    public ActionResult RegisterFlexiPA()
    {


        return View();
    }

    public ActionResult  RegisterFire()
    {
        return View();
    }

    public ActionResult RegisterMotor()
    {
        return View();
    }
  }
}

My ViewModel

    namespace Insurance.ViewModels
    { 
    public class RegisterInfoPA
    {
    public register reg { get; set; }
    public infoPA infoFlexiPA { get; set; }
    public personalInfo pinfo { get; set; }
    public List<maritalInfo> minfo { get; set; }
    public childInfo cInfo { get; set; }
    }
}

My view

@using (Html.BeginForm()) {
@Html.AntiForgeryToken()
@Html.ValidationSummary(true)

   <!--TITLE-->
    <div class="editor-label">
        Title
    </div>
    <div class="editor-field">
        @Html.EditorFor(model => model.reg.title)
        @Html.ValidationMessageFor(model => model.reg.title)
    </div>
    <!--NAME-->
    <div class="editor-label">
        Name
    </div>
    <div class="editor-field">
        @Html.EditorFor(model => model.reg.registerNm)
        @Html.ValidationMessageFor(model => model.reg.registerNm)
    </div>

    <!--IC NO-->
    <div class="editor-label">
        IC No
    </div>
    <div class="editor-field">
        @Html.EditorFor(model => model.reg.identityNo)
        @Html.ValidationMessageFor(model => model.reg.identityNo)
    </div>

        <!--GENDER-->
<div class="editor-label">
    Gender
</div>
<div class="editor-field">
    @Html.EditorFor(model => model.pinfo.gender)
    @Html.ValidationMessageFor(model => model.pinfo.gender)
</div>

    <!--Marital Status-->
    <div class="editor-label">
        **Marital Status**
    </div>
    <div class="editor-field">     
    </div>

Wanted to make the checkbox here for marital status eg :single,widowed,married

I am new to mvc, really appreciate your helps.




Aucun commentaire:

Enregistrer un commentaire