Scenario
I have a problem that utilizes a jquery repeater that way I can keep adding records in this case qualification records.
Problem
The problem I am experiencing is that I cannot get a Yes/No dropdown or checkbox to work or display the value that it reads from the database. As you can see,from the screenshot I can't select the value "no" to be displayed in my dropdown list, if true was selected, I wouldnt be able to get my checkbox to be "ticked"
The commented area of code shows some of the methods I've used, As you can see, I cant exactly bind act (Correct me here if im wrong) because it's part of another class so I cant say "Model.historyLead" or Model.act.historyLead. I am returning all the other values but it's just the checkbox or dropdown list is not working for me. I would greatly appreciate any help in solving this. Regards
Part of my edit view
@foreach (var item in Model.act)
{
<div data-repeater-item class="mt-repeater-item">
<div class="mt-repeater-input">
<label>Institution</label>
<input type="text" class="form-control" name="hisotryInput" value="@item.hisotryInput" />
</div>
<div class="mt-repeater-input">
<label>Description</label>
<div class="col-md-10">
@Html.TextArea("hisotrydescrip",item.hisotrydescrip, new { @class = "form-control", cols = 50, @rows = 5,@style="width:290px" })
</div>
</div>
<div class="mt-repeater-input">
<label>Lead Consultant?</label>
@*@Html.DropDownList("historyLead", null, String.Empty, new { @class = "form-control ", @Value = @item.historyLead })*@
@*@Html.CheckBox("historyLead", new { htmlAttributes = new { @class = "form-control",@value=@item.historyLead } })*@
<input type="checkbox" class="form-control" name="historyLead" value=@item.historyLead />
@*<select name="historyLead" >
<option value="volvo">Volvo</option>
<option value="saab">Saab</option>
<option value="vw">VW</option>
<option value="audi" selected>Audi</option>
</select>*@
</div>
And model used
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Web;
namespace CARICAD_App.Models
{
public class repeatViewModel
{
[Display(Name = "textinput")]
public string textinput { get; set; }
}
public class CON_consultantInfoVM
{
[DisplayName("Age Range")]
public Nullable<int> ageRange { get; set; }
public int id { get; set; }
[DisplayName("Image")]
public string image { get; set; }
[DisplayName("Consultant ID")]
public string consultID { get; set; }
[DisplayName("First Name")]
[Required]
public string firstName { get; set; }
...
public REF_country REF_country { get; set; }
public REF_nationality REF_nationality { get; set; }
public List<actVm> act { get; set; }
}
public class actVm
{
public Nullable<int> id { get; set; }
public string consultID { get; set; }
public string textinput { get; set; }
public string untypedinput { get; set; }
public string dateinput { get; set; }
public string textareainput { get; set; }
public string radioinput { get; set; }
public string selectinput { get; set; }
public string activities { get; set; }
public string hisotryInput { get; set; }
public string historydateinput { get; set; }
public string hisotrydescrip { get; set; }
public string historydateinputTo { get; set; }
public string historyLead { get; set; }
public bool historyCo { get; set; }
public List<string> multipleselectinput { get; set; }
}
}