我已經用數據庫中的圖片上傳了8個帶有圖片的產品,使用代碼第一個實體框架,並且所有的都在索引視圖中顯示,我只想顯示連續的前四個產品和後四個圖庫的第二個頁面,所以我該怎麼做。 ??這是我的代碼..我試圖使用@for循環,並告訴它前四個,但我沒有工作。如何在視圖中顯示前幾項?
public class Product
{
[Key]
public int ProductId { get; set; }
[Display(Name ="Name: ")]
public string Name { get; set; }
[Display(Name ="Description: ")]
public string Description { get; set; }
[Display(Name = "Price: ")]
public decimal Price { get; set; }
[Display(Name ="Discount: ")]
public double Discount { get; set; }
[Display(Name ="Quantity: ")]
public int Quantity { get; set; }
public int ImageSize { get; set; }
public string FileName { get; set; }
public byte[] ImageData { get; set;}
[NotMapped]
[Required]
public HttpPostedFileBase File { get; set; }
public virtual Order Order { get; set; }
}
發佈您目前嘗試過的循環代碼。您目前發佈的所有內容都是類定義。我們可以在視圖中使用 – CathalMF