on-internet
← Community

Show data from SQL database in Gridview

Stack Overflow ·

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

Comments

Sign in or sign up to comment and upvote.

No comments yet.