代码:
public ActionResult cbpnlNewUpdateConfigs(int id)
{
IEnumerable<StorageConfigurationModel> List = (IEnumerable<StorageConfigurationModel>)Session["ConfigurationList"];
foreach (StorageConfigurationModel configModel in List)
{
configModel.
}
return PartialView("cbpnlNewUpdateConfigs", new StorageConfigurationModel { });
}
所以我想在面板中显示模型的元素,所以我做了一个发送该信息的局部视图。但是当调用这个方法时,我必须查看我的所有列表,找到我想要的元素,然后发送该信息。当我在外观中时,我看不到模型的每一个属性。例如,我的模型中有一个 ID 和一个位置,但“configModel”看不到它们。
为什么?
澄清:在主视图中,我有一个带有接收列表的StorageConfigurationModel
网格视图的部分视图和一个带有回调面板的部分视图,它只接收一个StorageConfigurationModel
和:
public class StorageConfigurationModel
{
public int QueueMonitorConfigurationsID { get; set; }
public PathType QueueMonitorConfigTypeName { get; set; }
public string Location { get; set; }
public UnitType QueueMonitorValueTypeName { get; set; }
public ThresholdType Threshold { get; set; }
public int Value { get; set; }
}
public enum UnitType
{
MB, GB, TB, Files, Percentage
}
public enum ThresholdType
{
Upper, Lower
}
public enum PathType
{
Path
}
主要观点:
@model IEnumerable<BPM.Website.Models.StorageConfigurationModel>
@Html.Partial("gvConfigurations", Model)
@Html.Partial("cbpnlNewUpdateConfigs", new {id = -1})
因此,当我第一次加载时,我发送一个“-1”,以便面板加载为空。但是我在gridview(第一个局部视图)中单击编辑它会加载带有单击的id的面板的局部视图,因此它需要在列表中找到元素然后发送它。