Sathya Narayan

Sathya Narayan

  • NA
  • 155
  • 65.1k

MVC

Dec 17 2015 12:21 AM
HI,
 
I am beginner for MVC 4 so, i have an issue while retrieving the data from database.I am gettitng the  error like this may i know where exactly i am facing this issue.This is the error i am getting.
The model item passed into the dictionary is of type 'JeevesBO.ServiceBO', but this dictionary requires a model item of type 'System.Collections.Generic.IEnumerable`1[JeevesBO.ServiceBO]'.
 
Actually this is my code in controller.
 
public ActionResult ViewDetails(ServiceBO ServiceBO)
{
string partialView = null;
try
{
var valid = TryUpdateModel(ServiceBO);
objServiceBLL.SelectServiceByCaseID(ServiceBO);
if (valid)
{
objServiceBO._CaseID = "4I1-367BASC01-416003";
partialView = RenderPartialViewToString("_ViewDetails", objServiceBLL.SelectServiceByCaseID(objServiceBO));
//Messagedis = "Successfully Inserted";
}
}
catch (Exception ex)
{
return Json(new { Valid = false, Message = Messagedis, PatialView = partialView, status = 0 });
}
return Json(new { Valid = true, Message = Messagedis, PatialView = partialView, status = 1 });
}
This is views  ViewDetails.cshtml part.
 
@model JeevesBO.ServiceBO
<div class="panel-body">
<div class="row">
<div class="col-lg-4">
<div class="table-responsive">
<table class="table table-bordered table-hover table-striped">
<thead>
<tr>
<th>
Customer Name
</th>
<th>
Mobile Phone
</th>
<th>
HomePhone
</th>
</tr>
<tr>
<th>
Email
</th>
<th>
Address
</th>
<th>
LandMark
</th>
</tr>
</thead>
<tbody>
@if (Model != null)
{
foreach (var item in Model)
{
<tr>
<td>
@Html.DisplayFor(modelItem => item._CourierName)
</td>
<td>
@Html.DisplayFor(modelItem => item._MobilePhone)
</td>
<td>
@Html.DisplayFor(modelItem => item._HomePhone)
</td>
</tr>
<tr>
<td>
@Html.DisplayFor(modelItem => item._Email)
</td>
<td>
@Html.DisplayFor(modelItem => item._Address)
</td>
<td>
@Html.DisplayFor(modelItem => item._Landmark)
</td>
</tr>
}
}
</tbody>
</table>
</div>
<!-- /.table-responsive -->
</div>
<!-- /.col-lg-4 (nested) -->
<div class="col-lg-8">
<div id="morris-bar-chart"></div>
</div>
<!-- /.col-lg-8 (nested) -->
</div>
<!-- /.row -->
</div>
------------------------------------------------------------------------------------------------------------------
Index Part Index.cshtml
 
@model IEnumerable<JeevesBO.ServiceBO>
@{
ViewBag.Title = "Index";
Layout = "~/Views/Shared/_Layout.cshtml";
}
<h2>Index</h2>
@{Html.RenderPartial("~/Views/ViewCall/_ViewCallDetails.cshtml", new List<JeevesBO.ServiceBO> { new JeevesBO.ServiceBO() });}
  
 
 
 


 

Answers (1)