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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T15:22:41+00:00 2026-05-27T15:22:41+00:00

I am using asp.net mvc 3 and thinking what the best way to handle

  • 0

I am using asp.net mvc 3 and thinking what the best way to handle this scenario is.

Say I have a form that creates a reward structure. In this case their can be many levels of rewards

example

$100 to $500 - get .05% back
$501 to $1000 - get 0.6% back
$1001 to $1001 - get 0.7% back
and so forth.

Now these tiers are entered in the form I am creating. There could be one reward tier or there could be 5 tiers or 50 tiers. I just don’t know.

Option 1

Make an artificial limitation of say 5 tiers. If they only need one tier well they still have to go through the wizard form(through jquery) I am creating and skip the next 4 tier screens (there will be quite a few fields they will have to fill out so I decided to make it a wizard so it is not so overwhelming at once).

    public class MasterVm
    {
        public IList<TiersVm> Tiers { get; set; }

        public MasterVm()
        {
            Tiers = new List<TiersVm>();
        }
    }

@for (int i = 0; i < Model.Tiers.Count; i++)
{
    @Html.LabelFor(x => x.Tiers[i].StartOfRange, "Start Of Range")
    @Html.TextBoxFor(x => x.Tiers[i].StartOfRange)

    @Html.LabelFor(x => x.Tiers[i].EndOfRange, "End Of Range")
    @Html.TextBoxFor(x => x.Tiers[i].EndOfRange)

    // more fields here

}

In my controller I would make 5 placeholders so the for loop would go 5 times around.

Option 2

Make the form have a generate another tier button. They click on it and another tier would be made. This way if they only have one they only see it once and if they have 100 it does not matter.

I was thinking of using jquery clone to achieve this but I don’t know really how the view model binding works. Does it look at id’s? or the name?

When I do option one all my controls look like this

<input id="Tiers_0__StartOfRange" type="text" value="0" name="Tiers[0].StartOfRange">

They all have unique id’s(what is good) and unique names. I am unsure if in the clone code I should remove the id’s and the names. Or do I need to have code in there to generate id’s and names that look like above?

I will be submitting this all by ajax by using jquery.serializeArray() and in the controller I will have a parameter with the View Model is should bind too.

  • 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-27T15:22:42+00:00Added an answer on May 27, 2026 at 3:22 pm

    I don’t like the out of the box collection indexing pattern MVC3 uses. In our application, we use Steve Sanderson’s BeginCollectionItem HTML helper. It overrides the default behavior and uses GUID’s instead of integers to index the multiple items.

    I would suggest you do option #2, but do the cloning / collection item factory stuff on the server, and just return the HTML to the view using ajax. Steve’s helper works with the default model binder, so when you post your form, you will end up with a collection of tier models bound from the form inputs.

    Sample partial view for a single tier:

    @model TiersVm
    <div class="tier-item">
    @using(Html.BeginCollectionItem("Tiers"))
    {
        Html.LabelFor(x => x.StartOfRange, "Start Of Range")
        Html.TextBoxFor(x => x.StartOfRange)
    
        Html.LabelFor(x => x.EndOfRange, "End Of Range")
        Html.TextBoxFor(x => x.EndOfRange)
    
        // more fields here
    }
    </div>
    

    You would have an action method that returns the above partial when a user clicks “Add a tier” button.

    public PartialViewResult GenerateTier()
    {
        return PartialView(new TiersVm());
    }
    

    The BeginCollectionItem helper would render out all of your input names and id’s so that they could be rebound to the model you are POSTing in:

    @model MasterVm
    ... using BeginForm ....
    
    <div class="tier-container"> @* clicking new tier button appends items here *@
    @foreach (var tier in Model.Tiers)
    {
       Html.Action("GenerateTier", "ControllerName")
    }
    </div>
    

    Then magic happens with the default model binder

    [HttpPost]
    public ActionResult ReceiveInput(MasterVm masterVm)
    {
        // masterVm.Tiers has been populated by the default model binder
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an website on asp.net-mvc, I'm thinking of using paypal for payments, is
Using ASP.NET MVC 2.0, I have an actionlink that is used for comments on
I've been using ASP.Net MVC for a while now and I've been thinking that
I have an asp.net backend that creates Hierarchical Data based on IHierarchicalEnumerable. This was
Using ASP.Net MVC on my Site.Master I have: <head runat=server> <title><asp:ContentPlaceHolder ID=TitleContent runat=server />
Using ASP.Net MVC 2, is there any way to use the RedirectToAction() method of
I have an existing site build in c# 3.5 using asp.net mvc 1. There
I have been using ASP.NET MVC for six months or so and have been
I'm using a masterpage in my ASP.NET MVC project. This masterpage expects some ViewData
I have developed a web app in ASP.NET MVC which we are using internally.

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.