Ok so this would be after changes that you guys helped me with , im assuming im getting a syntax error somewhere
View
@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>
Model Clients
[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; }
}
Model Countys
[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; }
}
Countys controller
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 is returning an error but i cannot step into it ... to find out what it is ... ideas?