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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T02:23:04+00:00 2026-06-13T02:23:04+00:00

I’ve created a simple MVC application that takes information from a form and passes

  • 0

I’ve created a simple MVC application that takes information from a form and passes it to a controller

View:

@model MvcApplication1.Models.BetChargeModel


@using (Html.BeginForm())
{
<div>
    @Html.TextBoxFor(m=>m.numerators[0])   /   @Html.TextBoxFor(m=>m.denominators[0])
</div>

<div>
    @Html.TextBoxFor(m => m.numerators[1])   /   @Html.TextBoxFor(m => m.denominators[1])
</div>

<div>
    <input type="submit" value="Calculate" />
</div>
}

Controller:

 public ActionResult Index()
    {
        BetChargeModel model = new BetChargeModel();
        model.numerators = new List<double>();
        model.denominators = new List<double>();
        model.denominators.Add(1);
        model.denominators.Add(1);
        model.numerators.Add(0);
        model.numerators.Add(0);

        return View(model);
    }

[HttpPost]
    public ActionResult Index(BetChargeModel model)
    {
        double odds1 = model.numerators[0] / model.denominators[0];
        double odds = model.numerators[1] / model.denominators[1];

//other code
}

Model:

 public class BetChargeModel
{
    public List<double> numerators { get; set; }

    public List<double> denominators { get; set; }

    public double result { get; set; }

}

When I run this and try and post back information from the View the Model is coming back empty (full of null fields and zeros). Why is the data in my Textbox’s not binding to the model?

(Edit: I’ve changed the model properties and reference to Numerators, Denominators and Result but haven’t updated those here for sake of brevity)

  • 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-13T02:23:06+00:00Added an answer on June 13, 2026 at 2:23 am

    Based on the names numerators and denominators it looks like you have implemented the lists as fields on the model.

    You should use properties instead for the model binding to work properly (which I assume that @Raphael has done).

    A working model would look like this:

    public class BetChargeModel
    {
        public List<double> numerators { get; set; }
        public List<double> denominators { get; set; }
    }
    

    … and to follow to naming conventions, make sure to rename numerators to Numerators and denominators to Denominators.

    However, if this does not resolve your model binding issue, please elaborate and post your model implementation 🙂

    — UPDATE

    As you have reported that the issue still persists I will post the code I have implemented based on your own provided samples – then you can cross check to make sure everything looks right on your machine – the code shown in the following is tested and works:

    Model:

    public class BetChargeModel
    {
        public List<double> numerators { get; set; }
        public List<double> denominators { get; set; }
    }
    

    View:

    @model Project.Models.BetChargeModel
    
    @using (Html.BeginForm())
    {
    <div>
        @Html.TextBoxFor(m=>m.numerators[0])   /   @Html.TextBoxFor(m=>m.denominators[0])
    </div>
    
    <div>
        @Html.TextBoxFor(m => m.numerators[1])   /   @Html.TextBoxFor(m => m.denominators[1])
    </div>
    
    <div>
        <input type="submit" value="Calculate" />
    </div>
    }
    

    Controller:

    public ActionResult Index()
    {
        var model = new BetChargeModel
                        {
                            numerators = new List<double> {0, 0},
                            denominators = new List<double> {1, 1}
                        };
        return View(model);
    }
    
    [HttpPost]
    public ActionResult Index(BetChargeModel model)
    {
        var odds1 = model.numerators[0] / model.denominators[0];
        var odds = model.numerators[1] / model.denominators[1];
        return null;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a view passing on information from a database: def serve_article(request, id): served_article
I am doing a simple coin flipping experiment for class that involves flipping a
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a text area in my form which accepts all possible characters from
I have an MVC Razor view @{ ViewBag.Title = Index; var c = (char)146;
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I have a small JavaScript validation script that validates inputs based on Regex. I
For some reason, after submitting a string like this Jack’s Spindle from a text

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.