Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6073067
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T10:13:48+00:00 2026-05-23T10:13:48+00:00

Is this even possible? Maybe i am stupid but i cannot apply any of

  • 0

Is this even possible? Maybe i am stupid but i cannot apply any of the answers here or elsewhere to my specific situation.

What i want to do is pass a strongly typed model of Quiz to my view. Quiz has a collections of questions. Question has a collection of possibleanswers.

Questions look like:

  • Question.Text
  • Question.Id
  • Question.PossibleAnswers

PossibleAnswers look like:

  • PossibleAnswer.Id
  • PossibleAnswer.Value
  • PossibleAnswer.Label
  • PossibleAnswer.Selected

I want to pass the Quiz to the view, the view should setup the form where each Question has a radiobuttonlist(group) of PossibleAnswers.

Question1 text blah blah blah:

<input id="1_1" type="radio" name="question1"  value="1" />
<input id="1_2" type="radio" name="question1"  value="2" />
<input id="1_3" type="radio" name="question1"  value="3" />

Now i don’t care exactly the format for the id’s of the radio buttons in the group.. clearly MVC must care.. so whatever way works i want to do that. But i would expect when i submit the form to the action i should be able to loop through the Questions and get the possibleAnswer in each Question’s possibleAnswer collections with the .isAnswer marked as true:

foreach(var item in model.Questions)
{
    foreach(var aitem in item.PossibleAnswers)
    {
        if(aitem.Selected)
           //do some stuff
    }
}

so i don’t get it.. this:

@foreach (var item in Model.Questions)
{
    @foreach (var jitem in item.PossibleAnswers)
    {
        @Html.RadioButtonFor(x => item.QuestionId, jitem.Value)

    }

 }

is not even close.. can someone please explain what i am doing wrong? Is my model wrong? Can MVC do this? Do i need to change the PossibleAnswer model type to RadioButtonListItems or something? help!

———————————— ** UPDATE ** —————-

@for (int i = 0; i < Model.Questions.Count(); i++)
{      
    <p>@Model.Questions.ElementAt(i).QuestionText</p>
    @Html.RadioButtonListFor(m => m.Questions.ElementAt(i).AnswerRadios,
        "Question" + i);        
}

This code seems to work! At least it will output some radiobuttons.. BUT it is outputting the html as special entities..

<td id="Question0_Container">

    <input id="Question0_1" name="Question0_value" type="radio" value="17" />
    <label for="Question0_1">1</label>

    <input id="Question0_2" name="Question0_value" type="radio" value="18" />
    <label for="Question0_2">2</label>

    <input id="Question0_3" name="Question0_value" type="radio" value="19" />
    <label for="Question0_3">3</label>

    <input id="Question0_4" name="Question0_value" type="radio" value="20" />
    <label for="Question0_4">4</label>

    <input id="Question0_5" name="Question0_value" type="radio" value="21" />
    <label for="Question0_5">5</label>

</td>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T10:13:49+00:00Added an answer on May 23, 2026 at 10:13 am

    Here is what I use. I have made some minor modifications but it works great.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Ok, not sure if this is even possible, but I want to change the
Im having issues getting this to work, maybe its not even possible? I have
I don't even know if this is even possible, but I thought I'd ask.
I'm not sure if this is even possible, but is there a way to
It probably isn't even possible to do this, but I will ask anyway. Is
Is this even possible? Im learning DirectX atm and am trying to apply some
Not sure if this is even possible but I am trying to save text
This is not question about programming, but I think maybe I'll get some answers
I'm not even sure if this is possible, so apologies if it's a stupid
Okay, This may be really simple or it may not even be possible, or

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.