I am working on a project where users should be able to upload images and have them shown on their individual page as a grid gallery.
I have watched this tutorial to be able to upload images from the application to the database and show an image with a specific ID. It all works fine.
https://www.youtube.com/watch?v=5L5W-AE-sEs&
My view controller looks like this:
[HttpGet]
public ActionResult View(int id)
{
Image imageModel = new Image();
using (portfolio_project_dbEntities db = new portfolio_project_dbEntities())
{
imageModel = db.Images.Where(x => x.ImageID == id).FirstOrDefault();
}
return View(imageModel);
}
The view part:
<img src="@Url.Content(Model.ImagePath)" width="200"/>
Now I would like to be able to show multiple images on one page (images with the same userid) but I don't really understand how to do this. How do I pass multiple images from the controller to the view? Or maybe this is better to do in the view?
public List<Image> Images {get; set; }on it.