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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T16:40:45+00:00 2026-05-15T16:40:45+00:00

I’m trying to do this: Editing a variable length list, ASP.NET MVC 2-style In

  • 0

I’m trying to do this: Editing a variable length list, ASP.NET MVC 2-style

In the post he mentions that it could be done with less code using Html.EditorFor(), but that it would be more difficult because of the indexes. Well, that’s exactly what I want to do, and I don’t know where to begin.

I’m an ASP.NET novice who just completed the Nerd Dinner tutorial before jumping into a project at work, so any help would be appreciated.

Update 1: Instead of generating a GUID for each item in the collection, I’d like to generate incremental indexes starting with 0. Right now the field names look like “gifts[GUID].value”; I would like them to be “gifts[0].value”,”gifts1.value” etc. but I don’t understand how the collection keeps track and generates these indices.

  • 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-15T16:40:46+00:00Added an answer on May 15, 2026 at 4:40 pm

    Well, you begin by defining an editor template (~/Views/Shared/EditorTemplates/Gift.ascx):

    <%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<MyApp.Models.Gift>" %>
    <div class="editorRow">
        <% using(Html.BeginCollectionItem("gifts")) { %>
            Item: <%= Html.TextBoxFor(x => x.Name) %> 
            Value: $<%= Html.TextBoxFor(x => x.Price, new { size = 4 }) %> 
        <% } %>
    </div>
    

    And then replace the RenderPartial call with EditorForModel:

    <% using(Html.BeginForm()) { %>
        <div id="editorRows">
            <%= Html.EditorForModel() %>
        </div>
        <input type="submit" value="Finished" />
    <% } %>
    

    Once you’ve tried this you may come back and ask if you have any problems by explaining the symptoms.

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

Sidebar

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.