我有一个不能使用RowFilter进行过滤的DataTable,我将其带回了基础知识,但是仍然没有得到结果,根据microsoft documentation,这应该可以工作...
Environment_Details =具有所有记录的表
Item_Type_ID =这不是主键,只是行的属性(1 =应用程序,2 =服务器)
Parent_ID = Parent_ID字段和EI_ID字段(环境项目ID)之间的子代与父级关系
row = Environment_Details的当前行用单独的代码完成,此功能仅在服务器行上被命中(Item_Type_ID = 2),因此应用程序永远不会调用此方法。
Server_Check =只是通过
public ActionResult Server_Details(bool Server_Check, DataRow row, DataTable Environment_Details)
{
var model = new
ProjectOffice.Models.Forms.ServiceCatalogue.Environment.Delete_Environment_Item_Model();
DataView Application_List = new DataView(Environment_Details);
Application_List.RowFilter = "Item_Type_ID = 1";
//Application_List.RowFilter = "Parent_ID = {0}", row["EI_ID"]; //Removed for simplicity
ViewBag.row = row;
ViewBag.Application_List = Application_List;
ViewBag.Environment_ID = row["Environment_ID"];
ViewBag.Server_Check = Server_Check;
return PartialView("~/Views/Forms/ServiceCatalogue/Server/Server_Details.cshtml", model);
}
在视图中,我有:
@{
var Application_List = ViewBag.Application_List;
if (Application_List.Table.Rows.Count > 0)
{
bool check = false;
foreach (var App_List_Item in Application_List.Table.Rows)
{
@:<div class="panel-body">
Html.RenderAction("Application_Details", "Application", new { Application_Check = check, row = App_List_Item, Environment_ID = ViewBag.Environment_ID });
@:</div>
check = true;
}
}
}
我的结果仅返回包含2个服务器的完整数据集,但是,它仅应返回应用程序,而应用第二个过滤器时,它应仅返回特定于该服务器(行)的应用程序。
一些照片:
我应该使用ViewData代替ViewBag吗?
我的for循环写错了吗?
rowFilter值不正确吗? (应该是:“ Item_Type_ID = {0}”,1)
感谢您的帮助...