【发布时间】:2018-12-30 18:05:45
【问题描述】:
我目前正在开发 asp.net MVC 应用程序,我正在尝试绑定数据库中的列表数据。虽然它显示计数 = 124。
我在调试时从索引视图调用部分视图,它显示数据并为视图中的每个循环进行迭代,但无法在视图中加载它。
索引视图:
<div class="row">
<div class="col-lg-12">
<div class="panel panel-default">
<div class="panel-heading">
Debug Log
</div>
<!-- /.panel-heading -->
<div class="panel-body">
@if (Model.DebugLogReportList != null)
{
@Html.Partial("pv_DebugLogReport", Model)
}
</div>
<!-- /.panel-body -->
</div>
<!-- /.panel -->
</div>
局部视图:
如下截图所示,列表中有数据计数,
下面是控制器调用我的局部视图...
public ActionResult GetAll_DebugLogReport()
{
..........
return PartialView("pv_DebugLogReport", objLMT);
}
下面的结果屏幕,
请帮我知道原因。
【问题讨论】:
-
你确定没有隐藏表格的css(查看你页面的源代码来检查元素是否生成)
-
加载局部视图的方式应该使用 Index ActionResult 中的模型数据加载。但是,您为局部视图提供 Action 方法。你确定你已经理解流程了吗?加载索引时根本不应该触发您的操作方法 GetAll_DebugLogReport
-
我认为您正在尝试获取表格的服务器端呈现。这对您来说可能很方便 - datatables.net/forums/discussion/40690/… 注意 - 实施它是一次性成本,但您将获得它的其他好处,例如订购、搜索等。
-
@StephenMuecke 在查看源代码中,我看到没有生成任何元素
标签: asp.net asp.net-mvc asp.net-mvc-4 asp.net-mvc-3