好的,这将是在你们帮助我进行更改之后,我假设我在某处遇到语法错误
看法
@model OilNGasWeb.ModelData.Clients
@{
ViewBag.Title = "Index";
}
<h2>County's for </h2>
<p>
@Html.ActionLink("Create New", "Create",new { id = Model.ClientID },null)
</p>
<table>
<tr>
<th>
@Html.DisplayNameFor(model => model.County)
</th>
<th>
@Html.DisplayNameFor(model => model.Note)
</th>
<th>
@Html.DisplayNameFor(model => model.Comment)
</th>
</tr>
@foreach (var item in Model.Countys) {
<tr>
<td>
@Html.DisplayFor(modelItem => item.County)
</td>
<td>
@Html.DisplayFor(modelItem => item.Note)
</td>
<td>
@Html.DisplayFor(modelItem => item.Comment)
</td>
<td>
@Html.ActionLink("Edit", "Edit", new { id=item.CountyID })
@Html.ActionLink("Details", "Details", new { id=item.CountyID })
@Html.ActionLink("Delete", "Delete", new { id=item.CountyID })
</td>
</tr>
}
</table>
示范客户
[Table("Clients")]
public class Clients
{
[Key]
[DatabaseGeneratedAttribute(DatabaseGeneratedOption.Identity)]
public int ClientID { get; set; }
public string Client { get; set; }
public string Address { get; set; }
public string State { get; set; }
public string City { get; set; }
public string County { get; set; }
public int Zip { get; set; }
public string Phone { get; set; }
public string LogoLocation { get; set; }
public string ContactName { get; set; }
public string ContactPhone { get; set; }
public string ContactEmail { get; set; }
public int Authorized { get; set; }
public string Note { get; set; }
public string Comment { get; set; }
public virtual ICollection<Countys> Countys { get; set; }
}
示范县
[Table("Countys")]
public class Countys
{
[Key]
[DatabaseGeneratedAttribute(DatabaseGeneratedOption.Identity)]
public int CountyID { get; set; }
public int ClientID { get; set; }
public string County { get; set; }
public string Note { get; set; }
public string Comment { get; set; }
public virtual ICollection<TownShips> Townships { get; set; }
}
县控制器
public ActionResult Index(int id)
{
var cnty = from r in db.Clients
where r.ClientID == id
select r;
if (cnty != null)
{
return View(cnty); // View returns an error here
}
return HttpNotFound();
View 正在返回一个错误,但我无法进入它......找出它是什么......想法?