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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T07:49:17+00:00 2026-05-27T07:49:17+00:00

I am currently going through an MVC3 tutorial. Binding on an IEnumerable is done

  • 0

I am currently going through an MVC3 tutorial. Binding on an IEnumerable is done this way:

@ModelType IEnumerable(Of Product)

@foreach (var p in Model) {
   <div class="item">
      <h3>@p.Name</h3>
      @p.Description
      <h4>@p.Price.ToString("c")</h4>
   </div>
}

Is this the only to do this? It smacks of the old Classic ASP way of doing things. [shiver]

I can’t really identify what bothers me about it, it could be just the pains of transitioning from WebForms where code-behind is the King.

Someone please assuage my fears.

  • 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-27T07:49:17+00:00Added an answer on May 27, 2026 at 7:49 am

    It only smacks of it because you have code there.
    Data binding did what in web forms? It gave you something to set in code behind that ‘magically’ worked in your presentation layer usually by black magic and calling back into various methods noted in the xml markup. You couldn’t track what was doing what when, you passed ‘object e’ as eventargs, etc. it was messy.

    The above code is clean. Theres no calling back into code behind, and you don’t have to wait for a new version of a control to fix something for future browsers.

    ASP mixed BUSINESS LOGIC into the presentation layer. Your above code is the presentation layer only, so your code is fine.

    You could use WebGrid or Telerik’s grid (or MVCContrib) for better display and more ‘binding like’ stuff or you can use DisplayTemplates to customize this view so you can then just say Html.DisplayFor() wherever you use this object without having to repeat the above code.

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

Sidebar

Related Questions

I'm currently going through the ASP.NET MVC NerdDinner tutorial and am having a problem
I am currently going through the tutorial examples on http://code.google.com/p/stanford-cs193g-sp2010/ to learn CUDA. The
I'm going through a tutorial and it said this command, git branch -a would
I'm currently going through the Lynda Python tutorial and in the section on generators
I'm currently going through a RoR tutorial ( http://railstutorial.org/chapters/sign-in-sign-out#sec:signin_success is the relevant section) which
We are currently going through the long process of writing some coding standards for
I'm currently building a toy assembler in c# (going through The Elements Of Computing
i'm trying to make the following routes .. and currently i'm going about this
We currently use VSS 6, this is not going to change I am afraid.
I'm currently going through a few tutorials to get myself up and running on

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.