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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T06:31:25+00:00 2026-05-30T06:31:25+00:00

I have an MVC2 view which is strongly bound to a model. <%@ Page

  • 0

I have an MVC2 view which is strongly bound to a model.

<%@ Page Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<System.Collections.Generic.IEnumerable<AdjustmentModel>>" %>

And in the View I have.

         foreach (var adjustment in Model)
           {%>
         <tr row="<%: row %>">
            <td class="nonSelectable" column="0">
                <div>
                    ...I want to put a textbox here that has name="someId" 
                   and val="someVal" but how?
                </div>
            </td>

            }%>

The model is

class AdjustmentModel
{
    public int ID;
    public int amount;
}

I just can’t figure the delegate that I pass to Html.TextBoxFor() because when I pass a model the intellisense won’t work as I’m passing in an Ienumerable so how do I use the model?

  • 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-30T06:31:27+00:00Added an answer on May 30, 2026 at 6:31 am

    I would recommend you using editor templates. This way you don’t need to write any loops and still keep the strong typing:

    <table>
        <%= Html.EditorForModel() %>
    </table>
    

    and then you define an editor template which will be automatically rendered for each element of your collection (~/Views/Shared/EditorTemplates/AdjustmentModel.ascx):

    <%@ Control 
        Language="C#" 
        Inherits="System.Web.Mvc.ViewUserControl<AdjustmentModel>" 
    %>
    <tr>
        <td class="nonSelectable" column="0">
            <div>
                <%= Html.HiddenFor(x => x.ID) %>
                <%= Html.EditorFor(x => x.amount) %>
            </div>
        </td>
    </tr>
    

    It is important to respect the convention which is to locate your editor template inside the ~/Views/CurrentController/EditorTemplates or ~/Views/Shared/EditorTemplates folder. The name of the template must be the type used in the collection. So for example if you have IEnumerable<AdjustmentModel>, the file must be called AdjustmentModel.ascx and obviously strongly typed to AdjustmentModel. This template will then be automatically called for each element.

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

Sidebar

Related Questions

I have a strongly type View in an ASP.NET MVC2 application in which i
I'm using MVC2 with VS2010 I have a view that has two partial views
I have a MVC2 website which uses views from other assemblies. To do this,
I have a mvc2 application with a view like this <% using (Ajax.BeginForm(UserApprove, new
Im trying to get my strongly typed master page to work in my ASP
I'm building an asp.net MVC 2 app. I have a list view which lists
I have an ASP.NET MVC 2 web site in which I'd like to place
I have a web application which was using Asp.net MVC2 . I Upgraded it
I'm building a site using mvc2 and have a structure like follows: Factory ->
I have following markup which is generated dynamically using C# in my asp.net MVC2

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.