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 8740863
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T11:12:24+00:00 2026-06-13T11:12:24+00:00

In relation to this question: StackOverflow – Grouping radio buttons in c# mvc I

  • 0

In relation to this question:

StackOverflow – Grouping radio buttons in c# mvc

I have managed now to load and save the selected options from the form into a database but now the user may need to edit this.

How do I load the view with the selected user’s choices? I cannot see where you can set selected Answer. On load I am getting the default values selected

  • 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-13T11:12:25+00:00Added an answer on June 13, 2026 at 11:12 am

    You can set the SelectedAnswer property value for each Course in your GET action and your EditorTemplate will take care of the rest.

    public ActionResult Index()
    {
        var vm= new OrderViewModel();
    
        //the below is hard coded for DEMO. you may get the data from some  
        //other place and set the course and options
    
        var q1 = new Course { ID = 1, Name= "Starters" };
        q1.Options.Add(new Option{ ID = 12, Title = "Prawn Cocktail " });
        q1.Options.Add(new Option{ ID = 13, Title = "Soup" });
        q1.SelectedAnswer = 13; //to do : get the selected answer value from DB
    
        vm.Courses.Add(q1);     
    
        var q2 = new Course { ID = 1, Name= "Mains" };
        q2.Options.Add(new Option{ ID = 42, Title = "Beef" });
        q2.Options.Add(new Option{ ID = 43, Title = "Lamp" });
        q2.SelectedAnswer = 16;// to do :get the selected answer value from DB
    
        vm.Courses.Add(q2);
    
       return View(vm);           
    }
    

    There is no change to be made to your editor template. It stays same as the previous answer.

    @model Course
    <div>
        @Html.HiddenFor(x=>x.ID)
        <h3> @Model.Name</h3>
        @foreach (var a in Model.Options)
        {
           <p>
              @Html.RadioButtonFor(b=>b.SelectedAnswer,a.ID)  @a.Title
           </p>
        }
    </div>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My question is in relation this this answer. https://stackoverflow.com/a/8773953/1297775 I have read at many
Now, I have read these questions which may have a relation with this question:
In relation to this stackoverflow question , how would I go about creating my
In relation to this question ( Efficient hashCode() implementation ) I have one more
This question is in relation to a question I posted yesterday. The link -http://stackoverflow.com/questions/12636348/how-to-add-a-different-class-to-the-same-class-in-jquery
[This question is in relation to this question ] Setting : I have this
This question is in relation to a Plugin which I am now creating for
This question is in relation to another question I have asked, but what are
This question is in relation to another question I have: Using iBATIS.NET with generic
This is in relation to this question . The proposed answers involve adding a

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.