我正在尝试使用我的模型将一个数组从我的 Controller 传递到我的 View 。我的方法由于某种原因不起作用。我已经在下面发布了。
Controller :
public ActionResult Confirmation()
{
string[] Array = new string[2] {"Pending", "07/07/2013"};
ConfirmationModel Con = new ConfirmationModel
{
Status = Array[0],
AppDate = Array[1],
};
return View();
}
模型:
public class ConfirmationModel
{
public string Status { get; set; }
public string AppDate { get; set; }
}
看法:
@model site.ConfirmationModel
@{
ViewBag.Title = "Confirmation";
}
@Html.DisplayFor(Mode => Model.Status)
@Html.DisplayFor(Mode => Model.AppDate)
最佳答案
您没有将模型传递给您的 View 。更改以下行:
return View();
对此;
return View(Con);
关于c# - 使用模型将数组从 Controller 传递到 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18500514/