My Model is:
namespace MvcApplication5.Models
{
public class DepartmentModelClass
{
public int Id { get; set; }
public string Text1 { get; set; }
public string Text2 { get; set; }
public bool? Option1 { get; set; }
public bool Option2 { get; set; }
}
}
My Controller is:
public ActionResult Index()
{
List<DepartmentModelClass> list = new List<DepartmentModelClass>();
list.Add(new DepartmentModelClass { Id = 1, Text1 = "test1", Text2 = "test2", Option1 = false, Option2 = false });
list.Add(new DepartmentModelClass { Id = 2, Text1 = "test3", Text2 = "test4", Option1 = false, Option2 = false });
list.Add(new DepartmentModelClass { Id = 3, Text1 = "test5", Text2 = "test6", Option1 = false, Option2 = false });
return View(list);
}
My View Is:
@model IEnumerable<MvcApplication5.Models.DepartmentModelClass>
@{
Layout = null;
}
@using (Html.BeginForm("Index", "Employee", FormMethod.Post, new { id = "idForm" })) {
int i = 0;
foreach (var item in Model) {
<div class="row">
<div class="form-group">
<span>@i:</span>
<input type="text" id="idtext1" [email protected] name="[@i].Text1" />
<input type="text" id="idtext2" [email protected] name="[@i].Text2" />
<hr />
</div>
</div>
i += 1;
}
<input type="submit" value="Submit" />
}
My Screen is:
My Debug Is:
But, I would like to do same thing using RadioButtton:
<input type="radio" id="radio3" value="@item.Option1" name="[@i].Option1 == checked ? true : false" />
I want to set value TRUE or FALSE according my list item.
Can you help me? Thanks!


Can you please elaborate further.
Following is the code, if you want to display radio button based on the option1 value.