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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T05:29:57+00:00 2026-06-09T05:29:57+00:00

I am using razor view engine and having a bit of trouble creating a

  • 0

I am using razor view engine and having a bit of trouble creating a list of radiobutton.

I am populating a table with a for loop with the values of my model in my view.
at each row I want to have a radiobutton. I want to be able to select just one row and get the related items id from the model and submit it to another page. I know how to post. I actually achieved this by using checkbox. But the problem with checkbox is that it allows multiple selection.

So I guess I need to use radiobutton. Any help would be 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-09T05:29:59+00:00Added an answer on June 9, 2026 at 5:29 am

    Assuming you have a ViewModel like this

    public Class CheckOutViewModel
    {
      public string SelectedPaymentType { set; get; }
      public IEnumerable<SelectItems> PaymentTypes { set; get; }
    }
    

    And you are setting the PaymentTypes Collection in your GET Action method and sending it to the view which is strongly typed to CheckOutViewModel

    public ActionResult Checkout()
    {
      var vm=new CheckOutViewModel
      vm.PaymentTypes=GetPaymentTypes(); //gets a list of SelectItems
      return View(vm);
    }
    

    And in your View

    @model CheckOutViewModel
    @using(Html.BeginForm())
    {
      foreach (var paymentItem in Model.PaymentTypes)
      {
        @Html.RadioButtonFor(mbox => mbox.SelectedPaymentType, 
                                                  paymentItem.ID.ToString())       
        @paymentItem.Name    
      }
      <input type="submit" value="Save" />
    }
    

    Assuming GetPaymentTypes() method will return a list of SelectItems for your records in the database.

    This will give you the Radio buttons with the same name value(SelectedPaymentType). so only one can be selected.

    In your POST action, you can read the selected value by checking the SelectedPaymentType property value

    [HttpPost]
    public ActionResult Checkout(CheckOutViewModel model)
    {
      //check the value of model.SelectedPaymentType
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Having a little bit of trouble figuring out using a ternary with Razor view
I am having difficulty rendering a partial view using the MVC3 razor engine. When
Using the razor view engine, I have some code like the following: @Html.TextAreaFor(model =>
I am new in MS MVC3.I am using C# with razor view engine in
I am using mvc3 and razor is my view engine how i get date
I am using Mvc3 and my view engine is razor and also writing jquery
I'm using MVC3 with razor view. I'm giving the user a list of <li>
I am building wizard step demo application with MVC3 and using razor view engine
Is there any documentation on how to use the Razor view engine using ASP.NET
I am using ASP.NET MVC 3 with the Razor view engine . I have

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.