遇到ajax的问题我正在使用vs 2015 mvc 5。 以下是具有1对多关系的两个模型类。 我正面临一些问题。
namespace WebApplication1.Areas.Global.Models
{
public class Organization
{
public virtual int OrganizationId { get; set; }
public virtual int CityId { get; set; }
public virtual string Name { get; set; }
public virtual City city { get; set; }
}
public class City
{
public virtual int CityId { get; set; }
public virtual string Name { get; set; }
public virtual ICollection<Organization> Organization { get;set; }
}
}
&#13;
这是部分视图控制器..
public ActionResult Details(int? id)
{
if (id == null)
{
return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
}
City city = db.Cities.Find(id);
if (city == null)
{
return HttpNotFound();
}
return PartialView(city);
}
&#13;
<tr>
<td>
@Html.DisplayFor(modelItem => item.Name)
</td>
<td>
@Html.DropDownList("Organizations",new SelectList(item.Organization, "OrganizationId","Name"))
</td>
<td>
@Html.ActionLink("Edit", "Edit", new { id=item.CityId }) |
@Ajax.ActionLink("Details", "Details",item.CityId,
new AjaxOptions
{
UpdateTargetId = "detail",
Url = Url.Action("Details",item.CityId)
}, new { id=item.CityId }) |
@Html.ActionLink("Delete", "Delete", new { id=item.CityId })
</td>
</tr>
&#13;
我还在布局页面中渲染 jqueryval 包... 我的代码有任何问题请帮助....