I want to bind values(checked or not) to a @Html.CheckBox in MVC 3 through JQuery.
This is my HTML-
@using (Html.BeginForm())
{
IEnumerable<SelectListItem> Brands = ViewBag.GetBrands;
foreach (var item in Brands)
{
@Html.CheckBox("Brands", false, new{value = item.Value});
<label>@item.Text</label><br />
}}
This is what I tried-
function test {
var url = "/OfficeManagement/Offices/GetOfficeConfiguration";
var stringToReverse = rowData.ID;
var noCache = Date();
$.get(url, { officeID: stringToReverse, "noCache": noCache }, function (data) {
for(int i=0;i<data.Configuration.OfficeBrands.count;i++)
{
$('#Brands').attr('checked', data.Configuration.OfficeBrands[i]);
}
...............
}
<td>