我正在尝试显示我在视图中创建的列表,但仍然得到:"传入字典的模型项的类型为'System.Collections.Generic.List 1[System.String]', but this dictionary requires a model item of type 'System.Collections.Generic.IEnumerable1 [Standings.Models.Teams]'."
我的控制器:
public class HomeController : Controller
{
Teams tm = new Teams();
public ActionResult Index()
{
var model = tm.Name.ToList();
model.Add("Manchester United");
model.Add("Chelsea");
model.Add("Manchester City");
model.Add("Arsenal");
model.Add("Liverpool");
model.Add("Tottenham");
return View(model);
}
Run Code Online (Sandbox Code Playgroud)
我的模特:
public class Teams
{
public int Position { get; set; }
public string HomeGround {get; set;}
public string NickName {get; set;}
public int Founded { get; set; }
public List<string> Name = new List<string>(); …Run Code Online (Sandbox Code Playgroud) 我有一个应用程序asp.net mvc.在控制器中我有这个:
public ActionResult Index()
{
Upload.Models.ClientModels model1 = new Models.ClientModels();
ArrayList client = model1.Client_List();
Upload.Models.AkeoModels model2 = new Models.AkeoModels();
ArrayList akeo = model2.Akeo_List();
ArrayList model = new ArrayList();
model.Add(client);
model.Add(akeo);
return View(model);
}
Run Code Online (Sandbox Code Playgroud)
我将两个连接列表传递给视图索引作为模型:
@{
ViewBag.Title = "Bienvenue";
int i = 0;
}
<hgroup class="title">
<h1 style="color:darkcyan">Liste des clients</h1>
</hgroup>
<section >
<form>
<table style="margin-top: 50px;">
<tr ><td ></td>
<td ><center><b>Login</b></center></td>
<td><center><b>Email</b></center></td>
<td><center><b>Password</b></center></td>
<td><center><b>Name</b></center></td>
</tr>
@{
Upload.Models.ClientModels client = null;
int j = 0;
while( j != -1)
{ …Run Code Online (Sandbox Code Playgroud)