I'm using MVC, Have the following Model
public class Questionnaire
{
public string Name { get; set; }
public List<Question> Questions { get; set; }
}
and Question class is :
public class Question
{
public int QuestionNumber { get; set; }
public string Body { get; set; }
public IList<Option> Options { get; set; }
//public IEnumerable<CreativeFactory.Option> OptionsTemp { get; set; }
public Guid? QuestionnaireId { get; set; }
public Guid? SelectedOption { get; set; }
public int? SelectedEmployeeId { get; set; }
}
In my View I do foreach, and partially render a view
% Html.BeginForm("Submit", "Questionnaire", FormMethod.Post); %>
<%
foreach (var q in Model.Questions)
{
Html.RenderPartial("Question", q);
}
%>
<input type="submit" name="submit" value="submit" />
<% Html.EndForm(); %>
My problem is the passed model to my action is always null
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult Submit(Questionnaire m)
{
}
EDIT 1: Well, My Partial View Code is :
<%
foreach (var option in Model.Options)
{%>
<p/>
<%= Html.RadioButtonFor(x => x.SelectedOptionId, option.QuestionId, new { id = "test" + option.ID })%>
<%
}
%>
Even in the debugging Mode, I can't find my collection in the Form instance so even Custom Binding dosn't solve the problem, because the collection is not exist
any idea please?