все
Я пытаюсь использовать @ Html.CheckBoxFor.
Вот мой код:
Модель:
public bool WC0001 { get; set; }
Вид:
@using (Html.BeginForm("ListSearch", "Committee", FormMethod.Get))
{
@Html.CheckBoxFor(model => model.WC0001) <label for="WC0001" class="mrg_r20">Development</label>
}
Я также использую WebGrid.
Когда я нажимаю на страницу 2, я получаю эту ошибку.
Не удается неявно преобразовать тип 'string' в 'bool'
Итак, я посмотрел на URL.
Это "http://localhost:28685/Committee/ListSearch?WC0001=true%2cfalse&page=2"
Почему я получаю параметр WC0001 как true% 2cfalse?
И какой обходной путь для этого?
Это не случилось, когда я публиковал форму.
Но так как я изменил его как FormMethod.Get из-за WebGrid, это начало происходить.
Пожалуйста, кто-нибудь, помогите мне.
EDIT:
![enter image description here](https://i.stack.imgur.com/P7mV8.png)
Вот что происходит при перезагрузке страницы.
EDIT:
Вот мой код действия:
[HttpGet]
public ActionResult ListSearch(Kuksiwon.Models.Committee profile, FormCollection collection)
{
DataTable _dt = _bp.DtReturnS(false
, "WSP_KW100_R1"
, profile.APJIKJONGCODE == null ? "" : profile.APJIKJONGCODE
, profile.APKUKSICODE == null ? "" : profile.APKUKSICODE
, profile.CTNAME == null ? "" : profile.CTNAME
, collection["CTSEXList"] == null ? "" : collection["CTSEXList"].ToString()
, profile.CTOADDRESS1 == null ? "" : profile.CTOADDRESS1
, profile.CTOADDRESS2 == null ? "" : profile.CTOADDRESS2
, profile.CTUNIVCODE1 == null ? "" : profile.CTUNIVCODE1
, profile.CTHOSPCODE1 == null ? "" : profile.CTHOSPCODE1
, profile.CTETCNAME == null ? "" : profile.CTETCNAME
, profile.CTUNIVDIV1 == null ? "" : profile.CTUNIVDIV1
, profile.CTUNIVJIKUP1 == null ? "" : profile.CTUNIVJIKUP1
, profile.CTEMAIL == null ? "" : profile.CTEMAIL
, profile.WC0001 ? "WC0001" : ""
, profile.WC0002 ? "WC0002" : ""
, profile.WC0003 ? "WC0003" : ""
, profile.WC0004 ? "WC0004" : ""
, profile.WC0005 ? "WC0005" : ""
, profile.WC0006 ? "WC0006" : ""
, profile.WC0007 ? "WC0007" : ""
, profile.WC0008 ? "WC0008" : ""
, profile.WCNONE ? "1" : "0"
, profile.RSNAME == null ? "" : profile.RSNAME
, profile.BKNAME == null ? "" : profile.BKNAME
, profile.CTSUBJECT == null ? "" : profile.CTSUBJECT
, profile.CTCOLLEGE == null ? "" : profile.CTCOLLEGE
);
ViewBag.ListSearch = _dt;
profile.CTSEXList = profile.CommonCodeList("SX", "1");
return View(profile);
}