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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T22:07:47+00:00 2026-05-14T22:07:47+00:00

I am following a simple ADO.NET Entity/MVC 2 tutorial wherein my Views are created

  • 0

I am following a simple ADO.NET Entity/MVC 2 tutorial wherein my Views are created by right-clicking the action and selecting ‘Add View’. The views get created based on my model and all is good. I can view the initial list of items from the DB but when I click Edit or Delete or Details I get ‘Object reference not set to an instance of an object’. It acts like my data is not there at all so I’m thinking I may need to fill ViewData again?

Here is how I am getting the data:

CheckingEntities chk = new CheckingEntities();
        //
        // GET: /CheckingMVC/

        [Authorize]
        public ActionResult Index()
        {
            ViewData.Model = chk.tblCheckings.ToList();
            return View();
        }

And here is an example where I am getting the details:

// GET: /CheckingMVC/Details/5
         [Authorize]
        public ActionResult Details(int id)
        {
            return View();
        }

I suspect I have filled the ViewData incorrectly or need to do it again but don’t know where or how to do that. Still quite new to MVC.

  • 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-14T22:07:47+00:00Added an answer on May 14, 2026 at 10:07 pm

    The values passed to your Views must be populated on every request. Furthermore, values set inside your controller during a request cannot and will not be persisted between requests as every new requests creates a brand new set of controller instances from the controller factory.

    In your Details() action you are accepting an id and then returning your View without any data being placed in the Model. Instead try something along these lines:

    [Authorize]
    public ActionResult Details(int id)
    {
       var item = Entities.SomeEntitySet.SingleOrDefault(e => e.Id == id);
       return View("Details", item);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hi I am using the ADO.NET entity framework for the first time and the
Consider the following simple example: [DataContract({0}Base)] public class Base<T> where T : Entity<T> {
I am following the steps as outlined on MSDN Blogs > ADO.NET team blog
following simple code: <li><a href={{ path('_list') }}>List</a></li> is there a simple way to add
I have uploaded the following simple HTML code to http://losthobbit.net/temp/anchor.html <!DOCTYPE HTML PUBLIC -//W3C//DTD
Please, observe the following simple program (based on the example from the protobuf-net project
The following simple calculator expression grammar (BNF) can be easily parsed with the a
I have written the following simple test in trying to learn Castle Windsor's Fluent
We have the following simple Stored Procedure that runs as an overnight SQL server
Given the following simple example: List<string> list = new List<string>() { One, Two, Three,

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.