Please help my view is returning empty views yet i have records in the table employee.
@ModelType IEnumerable(Of Webgrid.Employee)
@Code
Layout = Nothing
End Code
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width" />
<title>Index3</title>
</head>
<body>
<p>
@Html.ActionLink("Create New", "Create")
</p>
<table class="table">
<tr>
<th>
@Html.DisplayNameFor(Function(model) model.LastName)
</th>
<th>
@Html.DisplayNameFor(Function(model) model.FirstName)
</th>
<th>
@Html.DisplayNameFor(Function(model) model.Title)
</th>
<th>
@Html.DisplayNameFor(Function(model) model.TitleOfCourtesy)
</th>
<th>
@Html.DisplayNameFor(Function(model) model.BirthDate)
</th>
<th>
@Html.DisplayNameFor(Function(model) model.HireDate)
</th>
<th>
@Html.DisplayNameFor(Function(model) model.Address)
</th>
<th>
@Html.DisplayNameFor(Function(model) model.City)
</th>
<th>
@Html.DisplayNameFor(Function(model) model.Region)
</th>
<th>
@Html.DisplayNameFor(Function(model) model.PostalCode)
</th>
<th>
@Html.DisplayNameFor(Function(model) model.Country)
</th>
<th>
@Html.DisplayNameFor(Function(model) model.HomePhone)
</th>
<th>
@Html.DisplayNameFor(Function(model) model.Extension)
</th>
<th>
@Html.DisplayNameFor(Function(model) model.Photo)
</th>
<th>
@Html.DisplayNameFor(Function(model) model.Notes)
</th>
<th>
@Html.DisplayNameFor(Function(model) model.ReportsTo)
</th>
<th>
@Html.DisplayNameFor(Function(model) model.PhotoPath)
</th>
<th></th>
</tr>
@For Each item In Model
@<tr>
<td>
@Html.DisplayFor(Function(modelItem) item.LastName)
</td>
<td>
@Html.DisplayFor(Function(modelItem) item.FirstName)
</td>
<td>
@Html.DisplayFor(Function(modelItem) item.Title)
</td>
<td>
@Html.DisplayFor(Function(modelItem) item.TitleOfCourtesy)
</td>
<td>
@Html.DisplayFor(Function(modelItem) item.BirthDate)
</td>
<td>
@Html.DisplayFor(Function(modelItem) item.HireDate)
</td>
<td>
@Html.DisplayFor(Function(modelItem) item.Address)
</td>
<td>
@Html.DisplayFor(Function(modelItem) item.City)
</td>
<td>
@Html.DisplayFor(Function(modelItem) item.Region)
</td>
<td>
@Html.DisplayFor(Function(modelItem) item.PostalCode)
</td>
<td>
@Html.DisplayFor(Function(modelItem) item.Country)
</td>
<td>
@Html.DisplayFor(Function(modelItem) item.HomePhone)
</td>
<td>
@Html.DisplayFor(Function(modelItem) item.Extension)
</td>
<td>
@Html.DisplayFor(Function(modelItem) item.Photo)
</td>
<td>
@Html.DisplayFor(Function(modelItem) item.Notes)
</td>
<td>
@Html.DisplayFor(Function(modelItem) item.ReportsTo)
</td>
<td>
@Html.DisplayFor(Function(modelItem) item.PhotoPath)
</td>
<td>
@Html.ActionLink("Edit", "Edit", New With {.id = item.EmployeeID }) |
@Html.ActionLink("Details", "Details", New With {.id = item.EmployeeID }) |
@Html.ActionLink("Delete", "Delete", New With {.id = item.EmployeeID })
</td>
</tr>
Next
</table>
</body>
</html>
Imports System.Web.Mvc
Imports System.Web
Imports System.Linq
Imports System.Data.SqlClient
Imports System.Data
Imports System.Configuration
Imports System.Collections.Generic
Imports System.Data.Entity
Imports Webgrid.Employee
Namespace Controllers
Public Class HomedController
Inherits Controller
' GET: Homed
Function Index() As ActionResult
Return View("AjaxMethod")
End Function
Function Index2() As ActionResult
Return View("AjaxMethod2")
End Function
<HttpGet>
Public Function Index3() As ActionResult
Dim entities As New NorthwindEntities()
Return View(entities.Employees.ToList())
End Function
<HttpPost>
Public Function AjaxMethod() As JsonResult
Dim entities As New NorthwindEntities
Dim customers As List(Of Employee) = (From customer In entities.Employees).ToList()
Return Json(customers)
' Dim countries As List(Of SelectListItem) = Entity..[Select](Function(x) New SelectListItem() With {
'.Text = x.Country,
'.Value = x.Country
'}).Distinct().ToList()
'Dim data As Object() = New Object() {customers, countries}
' Return Json(JsonConvert.SerializeObject(data))
End Function
End Class
End Namespace