Witam mam taki problem,
na stronie po zaznaczeniu checkboxów zwraca mi w modelu null.
Model
public class TReportsViewModel : GridViewModel
{
public List<COPerType> OprType = new List<COPerType>();
}
public class COPerType
{
private bool bCheck; // checked
private string bName; // name operation
#region getters/setters
public bool Check
{
get { return bCheck; }
set { bCheck = value; }
}
public string Name
{
get { return bName; }
set { bName = value; }
}
}
Controller
public ViewResult ActivityOpt()
{
TReportsViewModel tm = new TReportsViewModel();
string[] sOperationTypes = { "otwarcie nagrania", "eksport nagrania" };
tm.bAllOper = true;
for( int i = 0; i < sOperationTypes.Length;i++ )
{
COPerType opt = new COPerType();
opt.Check = false;
opt.Name = sOperationTypes[i];
tm.OprType.Add( opt );
}
return View("~/Views/Reports/ActivityOpt.cshtml", tm);
}
[HttpPost]
public ActionResult ActivityOpt(TReportsViewModel tvm)
{
}
View
@using( Html.BeginForm() )
{
@Html.ValidationSummary( true )
<table width="160" cellpadding="0" cellspacing="0" border="0" style="border:none">
@for( int l = 0; l < Model.OprType.Count;l++ )
{
<tr style="border:none">
<td style="border:none">
@Html.CheckBoxFor( x => x.OprType[l].Check )
@Html.DisplayFor( x => x.OprType[l].Name )
</td>
</tr>
}
</table>
<input type="submit" value="@Resources.OK" style="margin-left:0px;position:absolute"/>
}
po wysłaniu formularza mój model OprType = 0. Nie zwraca mi zaznaczonych checkbxów.
Z góry dziękuje i pozdrawiam
PiK