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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T08:17:49+00:00 2026-06-15T08:17:49+00:00

I have been reading and reading , and I can’t seem to get this

  • 0

I have been reading and reading , and I can’t seem to get this to work at all. I am very very new to asp.net MVC – after all the tutorials I read I finally got this much accomplished.

public class EventsController : Controller
{
    private EventsDBDataContext db = new EventsDBDataContext();
    public ActionResult Index()
    {
        var a = (from x in db.tblEvents
                 where x.StartDate >= DateTime.Now
                 select x).Take(20).ToList();
        return View(a);
    }
}

This is successfully finding 20 rows (like it is supposed to). Now how do I display these in the view ?? Does it have to be a strongly typed view?? It doesn’t seem like it should have to be… I have tried both , I tried typing a whole view, but for now it would be nice to just get one property of tblEvents to show up in the view. This is not working, I have tried many many variations.

@{foreach( var item in Model){

      @Html.DisplayFor( item.ID)

  }
}

How do I get the results from the controller displayed in the view? Just the ID is good for now – I can go from there.

  • 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-06-15T08:17:50+00:00Added an answer on June 15, 2026 at 8:17 am

    The problem is that your View doesn’t know what type your Model is. Use the @model syntax to define the type of your model.

    @model List<YourEventClass>
    
    @foreach( var item in Model )
    {
       @item.ID<br />
    }
    

    See i.e. here for more information

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

Sidebar

Related Questions

I have been reading all over the web about this and still can't understand
I have been reading hundreds of posts on ASP.NET blogs and questions on StackOverflow
I have been reading everything I can to find out how this can be
I have been reading the AssemblyFileVersion using code similar to this but can no
I have been reading articles about state management in ASP.NET for few days for
I have been reading for a while regarding Hibernate but I can't seem to
I have been reading up most questions on this item, but somehow I can't
Where can i get a tutorial on making dlls in qt?.I have been reading
I have been reading about the thread-pool pattern and I can't seem to find
Why can't you pass arrays as function arguments? I have been reading this C++

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.