Nagma Khan

Nagma Khan

  • NA
  • 126
  • 22.3k

I want to show sql table data in partial view of index

Oct 16 2017 8:19 AM
to show data in partial view 
I have created a Partial view on index
here is the index method
 
public ActionResult Index()
{
Big5OnlinePortalEntities db = new Big5OnlinePortalEntities();
var data = db.ExpoRegistrations.ToList();
return View(data); 
 
here is the partial view
 
@model IEnumerable<DataAccessOfExpo.ExpoRegistration>
@{
Layout = null;
}
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width" />
<title>Index</title>
</head>
<body>
<h4>Customers</h4>
<hr />
<table cellpadding="0" cellspacing="0">
<tr>
<th>ID</th>
<th>Email Id</th>
<th>User Name</th>
<th>Password</th>
<th>EditionName</th>
</tr>
@foreach (var ExpoRegistration in Model)
{
<tr>
<td>@ExpoRegistration.Id</td>
<td>@ExpoRegistration.EmailId</td>
<td>@ExpoRegistration.UserName</td>
<td>@ExpoRegistration.Password</td>
<td>@ExpoRegistration.EditionName</td>
</tr>
}
</table>
</body>
</html>
 
now it is showing error  'System.Data.Entity.Core.EntityException'
The underlying provider failed on Open.
can anyone help I am new to MVC 

Answers (2)