Read this article, "MVC uses non-Entity Framework to display data in view (ii)" Http://www.cnblogs.com/insus/p/3364482.html learned to display data from data tables in a database on a view. In a situation, I need to click on a record to see its detailed data.
The implementation of this function in MVC is actually very simple. We can first create a stored procedure in the database ([dbo].[ Usp_fruitcategory_getbyprimarykey]):
The primary key value of the incoming record to get the record. To modify the Fruitcategoryentity class in the models directory, add a function that returns ienumerable<fruitcategory> (Getfruitcategorybyprimarykey (byte FRUITCATEGORY_NBR)):
Next, we can modify the CategoryController.cs class in the Controllers directory.
Finally, the index.cxhtml view in the category directory, add a "detailed" column, and then create a details.cshtml view in this directory to display the details.
The most popular source program (. NET Framework 4.5 + C #) and Database (SQL Server 2014) files:
Http://download.cnblogs.com/insus/MVC/InsusMVCSiteCS_2013Oct13.rar
The following content was added on 2013-10-13 14:05, refactoring the Fruitcategoryentity class: