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

  • SEARCH
  • Home
  • 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 8531531
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T09:30:21+00:00 2026-06-11T09:30:21+00:00

I’ve just got myself into a little mess and am having trouble thinking myself

  • 0

I’ve just got myself into a little mess and am having trouble thinking myself out of it. I have the following domain model (reduced for brevity):

public class Questionnaire
{
    public int Id { get; set; }
    public IList<QuestionGroup> QuestionGroups { get; set; }
}

public class QuestionGroup
{
    public int Id { get; set; }
    public string Name { get; set; }
    public int Order { get; set; }
    public IList<Question> Questions { get; set; }
}

public class Question
{
    public int Id { get; set; }
    public string Text { get; set; }
    public string Type { get; set; }
    public string Headings { get; set; }
    public IList<Answer> Answers { get; set; }
}

public class Answer
{
    public int Id { get; set; }
    public string Text { get; set; } 
}

Now, when I’m rendering my Questionnaire in my view I’m using EditorTemplates for each QuestionGroup and Question. When rendering my Question I’m looking at the Type property (which is something like RadioButtonList or TextArea) and for each Heading (which is a comma separated string). So for example, let’s say we have a Question initialised like so:

var question = new Question() {
    Text = "My Question Text",
    Type = "RadioButtonList",
    Headings = "Very Difficult,2,3,4,Very Easy"
};

Then we would end up with this:

enter image description here

Which is produced in my EditorTemplate like so:

@foreach (var heading in Model.Headings.Split(','))
{
    <li>
        <div>
            <strong>@heading</strong>
            @Html.RadioButton(Model.Id.ToString(), heading)
        </div>
    </li>
}

The markup for this looks like this:

<ul>
    <li>
        <div>
            <strong>Very Difficult</strong>
            <input id="group_question_1" name="group.question.1" type="radio" value="Very Difficult" />
        </div>
    </li>
    <li>
        <div>
            <strong>2</strong>
            <input id="group_question_1" name="group.question.1" type="radio" value="2" />
        </div>
    </li>
    <li>
        <div>
            <strong>3</strong>
            <input id="group_question_1" name="group.question.1" type="radio" value="3" />
        </div>
    </li>
    <li>
        <div>
            <strong>4</strong>
            <input id="group_question_1" name="group.question.1" type="radio" value="4" />
        </div>
    </li>
    <li>
        <div>
            <strong>Very Easy</strong>
            <input id="group_question_1" name="group.question.1" type="radio" value="Very Easy" />
        </div>
    </li>
</ul>

I have produced a Custom Model Binder but this is where I’m a little stuck. My actual questions are:

  1. How do I persist the selected value based on my domain model in the view?
  2. Am I even using the correct approach for something like this, or am I way off?

I must admit, I’m still very much in the learning stage of MVC so I could be a bit blind-sided from my own attempt. Any help always appreciated!

  • 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-06-11T09:30:22+00:00Added an answer on June 11, 2026 at 9:30 am

    Managed to solve this using a custom model binder as mentioned in another question I asked: https://stackoverflow.com/a/12318484/961328

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I have a French site that I want to parse, but am running into
I'm having trouble keeping the paragraph square between the quote marks. In firefox the
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I have a jquery bug and I've been looking for hours now, I can't
I've got a string that has curly quotes in it. I'd like to replace

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.