我尝试从Controller渲染我的列表视图,但它显示错误。我确认桌子不是空的。
控制器如下所示:
控制器
public ActionResult Index()
{
var prbmembershipLists = prbmembershipRepo.PrbMembershipIndex();
return View(prbmembershipLists);
}
以下是错误指向第23行的存储库
存储库
public List<PrbMembershipViewModel> PrbMembershipIndex()
{
var listofprbmembership = entity.PRB_MEMBERSHIP_TYPE.Where(c => c.ACTION_STATUS != 2).ToList(); //Where(c => c.ACTION_STATUS != 2).
List<PrbMembershipViewModel> PrbMembershiplistfromModel = new List<PrbMembershipViewModel>();
foreach (var prbmerbershipItem in listofprbmembership)
{
PrbMembershipViewModel modelObj = new PrbMembershipViewModel()
{
PRB_MEMBERSHIP_TYPE_ID = prbmerbershipItem.PRB_MEMBERSHIP_TYPE_ID,
PRB_MEMBERSHIP_TYPE_NAME = prbmerbershipItem.PRB_MEMBERSHIP_TYPE_NAME,
PRB_ID = prbmerbershipItem.PRB_ID,
Prb = prbmerbershipItem.PRB.PRB_NAME,
ACTION_STATUS = (int)prbmerbershipItem.ACTION_STATUS,
CREATED_BY = prbmerbershipItem.CREATED_BY,
CREATED_DATE = prbmerbershipItem.CREATED_DATE,
DELETED_BY = prbmerbershipItem.DELETED_BY,
DELETED_DATE = prbmerbershipItem.DELETED_DATE,
LAST_UPDATE_BY = prbmerbershipItem.LAST_UPDATE_BY,
LAST_UPDATE_DATE = prbmerbershipItem.LAST_UPDATE_DATE
};
PrbMembershiplistfromModel.Add(modelObj);
}
return PrbMembershiplistfromModel;
}
我的视图如下所示
查看
@model IEnumerable<BPP.CCSP.Admin.Web.ViewModels.PrbMembershipViewModel>
@{
//Layout = null;
}
<div class="box box-primary box-body">
<table class="table table-striped table-bordered" id="dtaTable">
<thead class="dataTableHead">
@{
var i = 1;
}
@foreach (var item in Model)
{
<tr id="row_@item.PRB_MEMBERSHIP_TYPE_ID">
<td>@i</td>
<td>
@Html.DisplayFor(modelItem => item.PRB_MEMBERSHIP_TYPE_NAME)
</td>
<td>
@Html.DisplayFor(modelItem => item.Prb)
</td>
<td>
</td>
<td>
</td>
</tr>
i = i + 1;
}
</table>
<div class="modal fade" id="myModal">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<a href="#" class="close" data-dismiss="modal">×</a>
<h3 class="modal-title">Delete PRB membership Type</h3>
</div>
<div class="modal-body">
<h4>Are you sure you wish to delete this PRB Membership Type? </h4>
<div style="text-align:center;display:none" id="loaderDiv">
@*<img src="~/Content/InternetSlowdown_Day.gif" width="150" />*@
<img src="~/Content/images/ajax-loader.gif" width="60" />
</div>
</div>
<div class="modal-footer">
<a href="#" class="btn btn-default" data-dismiss="modal">Cancel</a>
<a href="#" class="btn btn-success" onclick="DeletePrbMembership()">Confirm</a>
</div>
</div>
</div>
</div>
@*hidden field for storing current PRB_MEMBERSHIP_TYPE_ID*@
<input type="hidden" id="hiddenPrbMembershipId" />
请问我该如何解决这个问题。
由于