c# - Posting Radiobuttonfor to different boolean fields whilst grouping then using name property returns null? -


i have radiobuttons nested within 2 loops, quiz , 1 radiobutton should selected each question, here second loop radiobutton is:

for (int k = 0; k < model[i].quizanswers.count(); k++)             {                 <li>                     @html.hiddenfor(model => model[i].quizanswers[k].correct)                     @html.radiobuttonfor(model => model[i].quizanswers[k].chosen, true, new { id = "radioanswer", @name = "n-" + @model[i].order, data_questionid = @model[i].order })                     @html.displayfor(model => model[i].quizanswers[k].answer)                 </li>             } 

in order stop user selecting multiple radiobuttons have grouped name attribute each set of radiobuttons above. each radiobutton posting true individual boolean field. without grouped name attribute radiobuttons post correctly, grouped name attribute not post. i'm guessing because grouping buttons using name attribute mvc assumes should returning single field. how can fix radiobuttons return true individual fields whilst @ same time being grouped 1 can selected?

edit - requested models follows, view model radio buttons posted too:

public class quizviewmodel {     public int quizquestionid { get; set; }     public int quizid { get; set; }     public int enrollmentid { get; set; }     public int oldcoursepageid { get; set; }     public string question { get; set; }     public int order { get; set; }     public int type { get; set; }     public ilist<quizanswers> quizanswers { get; set; } } 

the quizanswers model within viewmodel above:

public class quizanswers {     [key]     public int quizansid { get; set; }     public int quizquestionid { get; set; }     public string answer { get; set; }     public int order { get; set; }     public bool correct { get; set; }     public bool chosen { get; set; }      public virtual quizquestions quizquestions { get; set; } } 


Comments

Popular posts from this blog

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -