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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T14:12:28+00:00 2026-05-31T14:12:28+00:00

I am taking a prior question one step further (see this question ), I

  • 0

I am taking a prior question one step further (see this question), I am trying to figure out how to sum two (or more) selections the user makes with, for example, a radio button list. The selection the user makes is tied to an entity that contains a static currency value using if/else if statements.

These are the entities for price:

[DataType(DataType.Currency)]
[DisplayFormat(DataFormatString = "{0:c}")]
public decimal priceProcessingStandard = 0;

[DataType(DataType.Currency)]
[DisplayFormat(DataFormatString = "{0:c}")]
public decimal priceProcessingExpedited = 250;

[DataType(DataType.Currency)]
[DisplayFormat(DataFormatString = "{0:c}")]
public decimal priceSubmissionOnline = 0;

[DataType(DataType.Currency)]
[DisplayFormat(DataFormatString = "{0:c}")]
public decimal priceSubmissionManual = 200;

So, if I have two sets of if/else if statements such as:

@if (Model.ProcessingRadioButtons == Processing.Standard)
{
    @Html.DisplayFor(m => m.priceProcessingStandard)
}
else if (Model.ProcessingRadioButtons == Processing.Expedited)
{
    @Html.DisplayFor(m => m.priceProcessingExpedited)
}
...
@if (Model.SubmissionRadioButtons == Submission.Online)
{
    @Html.DisplayFor(m => m.priceSubmissionOnline)
}
else if (Model.SubmissionRadioButtons == Submission.Manual)
{
    @Html.DisplayFor(m => m.priceSubmissionManual)
}

and the user makes selections in the two separate radio button lists corresponding to Processing.Expedited and Submission.Manual, the code will respectively display $250.00 and $200.00.

I cannot, however, figure out how to sum those two to display $450.00. Bear in mind, I do not know the selections before hand, so doing priceProcessingExpedited + priceSubmissionManual in a function and then calling it will obviously not work. Also, I am doing about 10-15 of these but I only used two simple ones as an example of what I am trying to accomplish (so the fact that the other two choices are $0.00 doesn’t mean anything because there are varying prices for other choices that I left out).

Any guidance?

UPDATE:
Based on suggestion in answer, I am doing this:

Model.calculated =
    Model.priceSolution +
    ((Model.ProcessingRadioButtons == Processing.Standard) ?
    Model.priceProcessingStandard :
    (Model.ProcessingRadioButtons == Processing.Expedited) ?
    Model.priceProcessingExpedited :
    Model.priceProcessingUrgent);

Some notes:

  1. priceSolution is a static value that I use as a base (it’s the base value plus the user selections).
  2. I am using calculated in the ViewModel and get; set;‘ing it.
  3. I left out the Namespace.ViewModels.MyData before Processing. for brevity.
  4. I left out Submission for brevity as it’s just a + then the same logic as in Processing.
  • 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-05-31T14:12:29+00:00Added an answer on May 31, 2026 at 2:12 pm

    You do know the selections before hand considering your @if (Model.SubmissionRadioButtions == Submission.Online) is a test against values currently held by the model – even if this is only after a POST.

    As such, you should create a property in your view model that also performs these tests and sums the appropriate fields.

    If you don’t want this property displayed before the POST, make the property return a nullable type and wrap the view with @if(MySum.HasValue) { @Html.DisplayFor(m=>m.MySum) }

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

Sidebar

Related Questions

Taking shs's question a step further... Why isn't all government sponsored software open source?
Taking this question about beautiful XSL but getting more specific, how should I refactor
After taking a look at this SO question and doing my own research, it
Taking Sql this quarter and not having any luck with the following question: The
This is probably a very stupid math question, but i can't seem to figure
Taking advice from this post , I purchased a copy of 'The C Programming
Taking this article on classes and structs as an example: http://msdn.microsoft.com/en-us/library/ms173109.aspx namespace ProgrammingGuide {
Taking out all of the obvious caveats related to benchmarks and benchmark comparison, is
Taking the jQuery framework for example, if you run code like this: $(document).ready(function init()
Taking a look at my question HERE , I now want to return the

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.