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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T02:14:11+00:00 2026-05-25T02:14:11+00:00

I am following Steven Sanderson’s blog post here to create an editable and variable

  • 0

I am following Steven Sanderson’s blog post here to create an editable and variable length list of items. In his post he uses divs to display a new item in the list but I am using a table. Thus, my partial view for each item is rendering a tr tag with the various fields to edit. Right now my partial view looks something like this:

<tr>                
       @using (Html.BeginCollectionItem("LineItems"))
       {             
            <td>        
                @Html.TextBoxFor(m => m.Description)
                @Html.ValidationMessageFor(m => m.Description)                              
            </td>
            <td>
                @Html.TextBoxFor(m => m.Quantity)        
                @Html.ValidationMessageFor(m => m.Quantity)
            </td>
            <td>
                @Html.TextBoxFor(m => m.Amount)          
                @Html.ValidationMessageFor(m => m.Amount)       
            </td>
       }       
</tr>

This actually renders correctly on all browsers I have tested but the problem is that this really generates invalid HTML as it places a hidden input tag right after the opening tr tag.

<tr>
   <input type="hidden" name="LineItems.index" .... />
   <td>
      ...
   </td>
   ...
</tr>

There is a comment by another user on the linked post that says you can move the using statement into the first tag and it works but I haven’t been able to get this to work using ASP.NET MVC 3 and the Razor view engine.

Does anyone have any idea how to use the logic presented by Steven Sanderson but get the hidden index input field inside the first td so as not to generate invalid HTML?

Thanks

  • 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-25T02:14:12+00:00Added an answer on May 25, 2026 at 2:14 am

    After a bit of experimenting I came up with:

    <tr>                
       <td>        
       @using (Html.BeginCollectionItem("LineItems"))
       {             
                @Html.TextBoxFor(m => m.Description)
                @Html.ValidationMessageFor(m => m.Description)                              
            @:</td>
            @:<td>
                @Html.TextBoxFor(m => m.Quantity)        
                @Html.ValidationMessageFor(m => m.Quantity)
            @:</td>
            @:<td>
                @Html.TextBoxFor(m => m.Amount)          
                @Html.ValidationMessageFor(m => m.Amount)       
       }       
       </td>
    </tr>
    

    that did the trick for me.

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

Sidebar

Related Questions

Dear Experts, I am following Mr.Steve Sanderson Example for working with variable length list,
Dear Experts, I am following [Mr.Steve Sanderson Example][1] for working with variable length list,
I am creating list of checkboxes in partial view by follwoing http://blog.stevensanderson.com/2010/01/28/editing-a-variable-length-list-aspnet-mvc-2-style/ code and
Here's example from Steve Sanderson's blog demonstrating a containerless IF statement in knockout: <h3>Products</h3>
I was following Steven Sanderson's ' Pro ASP.NET MVC Framework ' book. On page
I am trying to following book : Pro ASP.NET MVC Framework by Steven Sanderson
I am new to MVC and I have been following Steven Andersons Pro ASP.Net
I am currently using Steven Sanderson book Pro ASP.NET MVC 2 Framework. But I
In the MVC 3 book by Steven Sanderson on p185 at the bottom, the
I'm following Steve Sanderson's example from this ASP.NET MVC book on creating a model

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.