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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T14:44:53+00:00 2026-06-11T14:44:53+00:00

I have a MVC3 Razor form. It have a radiobutton list and some another

  • 0

I have a MVC3 Razor form. It have a radiobutton list and some another text fields. When I press submit controller post action get the view model, which have all fields seted correctly, except RegionID.

Model:

    namespace SSHS.Models.RecorderModels
    {
        public class CreateViewModel
        {
             ...
             public int RegionID { get; set; }
             ...
        }
    }

Controller:

    namespace SSHS.Controllers
    {
        public class RecorderController : Controller
        {
            ...
            public ActionResult Create()
            {
                EntrantDBEntities db = new EntrantDBEntities();

                List Regions = new List(db.Region); 
                List Schools = new List(db.School);
                List Settlements = new List(db.settlement);

                CreateViewModel newEntr = new CreateViewModel();

                ViewBag.Regions = Regions;
                ViewBag.Schools = Schools;
                ViewBag.Settlements = Settlements;

                return View(newEntr);
            }

            [HttpPost]
            public ActionResult Create(CreateViewModel m)
            {
                EntrantDBEntities db = new EntrantDBEntities();

                Entrant e = new Entrant()
                {
                    FatherName = m.FatherName,
                    Lastname = m.LastName,
                    LocalAddress = m.LocalAddress,
                    Name = m.Name,
                    RegionID = m.RegionID,
                    PassportID = m.PassportID,
                    SchoolID = m.SchoolID,
                    SettlementID = m.SattlementID,
                    TaxID = m.TaxID,
                };

                db.Entrant.AddObject(e);
                db.SaveChanges();

                return RedirectToAction("Index");
            }
    }

View:

    @model SSHS.Models.RecorderModels.CreateViewModel
    @using SSHS.Models 

    @using (Html.BeginForm("Create", "Recorder", FormMethod.Post))
    {       
    
    
        @foreach (Region item in ViewBag.Regions)
        {
           
           @Html.RadioButtonFor(m => m.RegionID, item.RegionID)
           @Html.Label(item.RegionName) - @item.RegionID
           
        }
    
          ...
          ...    
    
    }

The Create(CreateViewModel m) method gets data from all textboxes normaly, but RegionID always is 0.

  • 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-11T14:44:54+00:00Added an answer on June 11, 2026 at 2:44 pm

    How are you planning to fill radio button with int ? It have two states: checked and not. Could you tell us, what are you trying to do? Make radio group? Use bool for RadioButtonFor.

    Added:

    You need to write something like this: CheckboxList in MVC3.0 (in your example you will have radio buttons)

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

Sidebar

Related Questions

Using MVC3 Razor, I have a partial view with some text, two text boxes
I have an existing SqlConnection conn; in some controller (using ASP.NET MVC3 + Razor
I have a action link on my MVC3 razor view. Which have a action
In a ASP.NET MVC3 Razor project I have 2 Models public class Post {
I have online form builder appplication in ASP.NET MVC3 with Razor views. It is
I have a MVC3 razor form where I use @Html.ValidationSummary(false) It displays all errors
I have a Razor MVC3 project which has two user records in a form,
I have an ASP.NET MVC3 web application with C# and Razor. Through a form
Using MVC3, C#, and the Razor View Engine: I have a form that has
I have below form written in mvc3 razor. I want to display a message

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.