asp.net - Listing Models from ASP pages, with Visual Studio and C# -


I am creating a very basic web application in Visual Studio in ASP, I used the default web site and Then the 'staff' ideal. This model can be stored using the database:

  Public class EmployeeDBContext: DbContext {public DbSet & lt; Employee & gt; Employee {receive; Set; }}   

In the employee namespace. When I created the controller for this model, make Default, Read, Update and Delete methods are created. An index page has also been created which is shown for the first time the page is loaded and this page shows to every employee currently in the database. The code for index.cshtml looks like this:

  @modelimimableable & lt; Other webpages Models. Employee & gt; @ {ViewBag.Title = "Index"; } & Lt; H2 & gt; All employee options & lt; / H2 & gt; & Lt; P & gt; @htmlexactionlink ("create new", "create") & lt; / P & gt; & Lt; P & gt; @htmlexactlink ("see all", "see now") & lt; / P & gt; & Lt; Table class = "table" & gt; & Lt; TR & gt; & Lt; Th & gt; @ Html.DisplayNameFor (model = & gt; model.Name) & lt; / Th & gt; & Lt; Th & gt; @ Html.DisplayNameFor (model => model.Role) & lt; / Th & gt; & Lt; Th & gt; & Lt; P & gt; Option & lt; / P & gt; & Lt; / Th & gt; & Lt; / TR & gt; @forcha (Miscellaneous items in the model) {& lt; Tr & gt; & Lt; TD & gt; @html DisplayFor (Model Isthm = & gt; Item Names) & lt; / Td> & Lt; TD & gt; @html Displayer (Model Itam => Item Roll) & lt; / Td> & Lt; TD & gt; @HTMLconnect ("edit", "edit", new id / ITIIDID}). @html.exe link ("description", "description", new {id = item.ID}). @ Html.ActionLink ("Delete", "Delete", New {id = item.ID}) & lt; / Td> & Lt; / TR & gt; } & Lt; / Table & gt;   

What I'm trying to do, is displaying a basic menu on index.cshtml and linking viewers with all the table of employees on all pages The problem is that ' The object is not set for an instance of the reference object. ' And the page is not displayed. I do not know why this code works on index.cshtml but will not work on ViewAll.cshtml, anybody have suggestions ?? Here's a link to some of the tutorials:

Thanks for any advice.

Just to clarify this problem was done with Employee Controller, where ViewAll related to the page The scene was going back. When View function looks like this:

  View public functionsAll () {return view (); }   

Employee list can not be accessed so much

  @modelimimableable   

was nullified. The correct version of this function is:

  Public Actions View ViewAll () {Return View (DB Employee). List ()); }   

Now the list of all employees is accessible and can easily be displayed on ViewAll page. Hope this is of help to anyone, if anyone has a Forth question then please ask !!

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -