public ActionResult Index(int directoryID)
{
Someclass sc = new Someclass();
DataTable dt = sc.method("directory");
return View(dt);
}
public ActionResult PlotPartial(DataTable dt)
{
return PartialView(dt);
}
上面的索引方法返回一个数据表到 IndexView 工作正常。在同一个视图中,我有一个按钮,它应该加载 PartialView“PlotPartial”,传递整个模型,即数据表。如何在不创建数据表实例两次的情况下最有效地实现这一点。我可以在两种操作方法中共享数据表吗?我想要部分视图中的整个数据表。它没有任何 id 列。
阿贾克斯代码:
$('#btnPlot').click(function () {
$.ajax({
url: '/Home/PlotPartial',
contentType: 'application/html; charset=utf-8',
data: { dt : @model },
type: 'GET',
dataType: 'html'
})
.success(function (result) {
$('#panelB').html(result);
})
.error(function (xhr, status) {
alert(status);
})
});
在上面的代码行“数据:{ dt:@model }”不起作用。
有人可以帮忙吗