@Html.CheckBox
JQueryを介してMVC 3の値(チェックされているかどうかに関係なく)をバインドしたい。
これは私の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 />
}}
これは私が試したものです-
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]);
}
...............
}