我正在嘗試爲我的問題創建RadioButtonFor或CheckBoxFor。我創造了這個模式:RadioButtonFor在asp.net mvc只創建一個單選按鈕
public class Question { public int ID { get; set; } public string Question1 { get; set; } } public class Answer { public int ID { get; set; } public string Answer1 { get; set; } public int QId { get; set; } } public class AnModelView { public Answer Answers { get; set; } public IQueryable<Question> Questions { get; set; } }
在我看來,我想這一點:
<%:Html.RadioButtonFor(model => model.Answers.QId, new SelectList(Model.Questions.Select(qu => new RadioButtonList { DataValueField = qu.ID.ToString(), DataTextField = qu.Question1 }), "Value", "Text"))%>
但產量只有一個單選按鈕。我如何獲得多個單選按鈕 - 每個答案都有一個
你可以使用radioibuttonlist助手從這裏:http://awesome.codeplex.com – Omu 2011-05-20 17:21:48