Click here to Skip to main content
15,881,938 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
hello, i added the questions and options in DB how i can load them like this with radio buttons
P.s Every option has a weight like Excellent = 10 , very good =7 , good = 5 :
what i should write in controller to get the questions and their options

1. what is your opinion in our service :

a. excellent b. very good c. good

2. what is your opinion in our customer service :

a. excellent b. very good c. good


What I have tried:

this is my View : 
<pre><pre><pre lang="HTML">
@using (Html.BeginForm())
{
    for (int i = 0; i < Model.Questions.Count(); i++)
    {
        @Html.TextBoxFor(model => model.Questions[i].QuestionText, new { placeholder = "Text" })
        <table>
            @for (int j = 0; j < Model.Questions[i].Answers.Count(); j++)
            {
                <!-- Answer block -->
                <tr>
                    <td>@Html.RadioButtonFor(model => model.Questions[i].Answers[j].IsCorrect)</td>
                    <td>@Html.TextBoxFor(model => model.Questions[i].Answers[j].AnswerText)</td>
                </tr>
            }
        </table>
        @Html.TextBoxFor(model => model.Questions[i].QuestionComment)
        <!-- Question block END -->
    }
    <input type="submit"/>
Posted
Updated 30-Aug-18 5:49am

1 solution

See: Radio button list in ASP.NET MVC[^]

That should help you get started how to build questions with radio buttons and handling answers.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900