Show data from SQL database in Gridview
I want to show data in grid view using 3 tables in SQL database. first I created Model public class common { public Artist Artist { get; set; } public Album Album { get; set; } public Genre Genre { get; set; } } Then This is the Controller public ActionResult Show1() { var query = from a in DB.Album join b in DB.Artists on a.ArtistId equals b.ArtistId join c in DB.Genre on a.GenreId equals c.GenreId where (b.ArtistId == 2) select new common { Album = a, Artist = b, Genre = c }; return View(query.ToList()); } } After that this is my View @model IEnumerable<test1.Models.common> @{ ViewBag.Title
0 upvotes
View original discussion ↗
Comments
Sign in or sign up to comment and upvote.
No comments yet.