0
如何綁定mvc中的單選按鈕,因爲我的視圖是這樣的?IList中的單選按鈕綁定<model > mvc視圖
@model IList<CMM.Models.Question>
@using (Html.BeginForm("Index", "Ques", new { ReturnUrl = ViewBag.ReturnUrl }, FormMethod.Post, new { @class = "form-3" }))
{
@foreach (var item in Model)
{
@Html.RadioButtonFor(item.QuestionId,item.QuestionId,item)//error in this line
@Html.RadioButtonFor(item.QuestionId,item.QuestionId,item)//error in this line
}
<input type="submit" value="Save" />
}
我只想要爲每一行檢查一個單選按鈕。並從數據傳遞給我的controller.My控制器是這樣的。
[HttpPost]
public ActionResult Index(IList<Question> sq)
{
return View();
}
我該如何顯示單選按鈕。我想在無線電中使用3個功能。
1)different id's
2)different values
3)javascript func call onclick of radio button..
在此先感謝...
而不是「RadioButtonFor」嘗試「RadioButton」來代替。 –
你可以展示你的問題模型嗎? –
看看這裏它覆蓋你的情況: http://stackoverflow.com/a/6640157/2932724 –