我正在尝试为我的问题创建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