mhd.mirzayi
یک شنبه 24 شهریور 1392, 09:12 صبح
سلا دوستان عزیز،
من دو تا کلاس دارم یکیCatagory و دیگریProductمی خوام یه لیست از عنوان Catagoryرو نمایش بدم و با کلیک بر روی هر یک از Catagoryها محصولات مربوط به او رو در پایین نمایش بدم البته این کار رو می خوام با ای جکس انجام بدم:
public class Cat
{
public int Id { get; set; }
public string Title { get; set; }
public ICollection<Product> Products { get; set; }
public ICollection<Photo> Photos { get; set; }
}
public class Product
{
public int Id { get; set; }
public string Title { get; set; }
public string Description { get; set; }
public Cat cat { get; set; }
public ICollection<Photo> Photos { get; set; }
}
public class Photo
{
public int id { get; set; }
public string Description { get; set; }
public ICollection<Cat> Cats { get; set; }
public ICollection<Product> Products { get; set; }
}
public class ProductDbContext : DbContext
{
public DbSet<Product> Products { get; set; }
public DbSet<Cat> Cats { get; set; }
public DbSet<Photo> Photos { get; set; }
}
حالا توی یه ویو این کد رو نوشتم:
@model IEnumerable<MvcProduct.Models.Cat>
@{
ViewBag.Title = "CatList";
}
<h2>CatList</h2>
@foreach (var item in Model)
{
string str=Html.DisplayFor(modelitem=>item.Title).ToString();
Ajax.ActionLink(str, "CatList", new AjaxOptions { UpdateTargetId = "DivProduct", InsertionMode = InsertionMode.Replace, HttpMethod = "Get" })
}
در واقع من می خوام عنوان کتگوری ها رو توی یه لینک ای جکس نشون بدم ولی نمیشه
کسی می تونه راهنماییم کنه
سپاس
من دو تا کلاس دارم یکیCatagory و دیگریProductمی خوام یه لیست از عنوان Catagoryرو نمایش بدم و با کلیک بر روی هر یک از Catagoryها محصولات مربوط به او رو در پایین نمایش بدم البته این کار رو می خوام با ای جکس انجام بدم:
public class Cat
{
public int Id { get; set; }
public string Title { get; set; }
public ICollection<Product> Products { get; set; }
public ICollection<Photo> Photos { get; set; }
}
public class Product
{
public int Id { get; set; }
public string Title { get; set; }
public string Description { get; set; }
public Cat cat { get; set; }
public ICollection<Photo> Photos { get; set; }
}
public class Photo
{
public int id { get; set; }
public string Description { get; set; }
public ICollection<Cat> Cats { get; set; }
public ICollection<Product> Products { get; set; }
}
public class ProductDbContext : DbContext
{
public DbSet<Product> Products { get; set; }
public DbSet<Cat> Cats { get; set; }
public DbSet<Photo> Photos { get; set; }
}
حالا توی یه ویو این کد رو نوشتم:
@model IEnumerable<MvcProduct.Models.Cat>
@{
ViewBag.Title = "CatList";
}
<h2>CatList</h2>
@foreach (var item in Model)
{
string str=Html.DisplayFor(modelitem=>item.Title).ToString();
Ajax.ActionLink(str, "CatList", new AjaxOptions { UpdateTargetId = "DivProduct", InsertionMode = InsertionMode.Replace, HttpMethod = "Get" })
}
در واقع من می خوام عنوان کتگوری ها رو توی یه لینک ای جکس نشون بدم ولی نمیشه
کسی می تونه راهنماییم کنه
سپاس