c# - creating a dynamic page in asp.net mvc -
i'm new asp.net mvc , i'm trying create dynamic page using following code....
`@using musicstore.models; @{ viewbag.title = "songs"; ienumerable<songs> songs = viewbag.songslist; } <section id="main" class="container"> <div class="jumbotron"> <h1> tony's music store</h1> <h2>@viewbag.title.</h2> </div> <table class="table"> <thead> <tr> <th><h3>song list</h3></th> </tr> </thead> @foreach (var list in songs) { <tbody> <tr> *<td><a href=" ">@list.songname</a></td>* </tr> </tbody> } </table> </section>`
i want reference page "song details", when u click on 1 of listed songs *<td><a href=" ">@list.songname</a></td>*
should display details of song , if song clicked, same page opened displaying details of specific song clicked.
this songs model code....
using system; using system.collections.generic; using system.linq; using system.web; namespace musicstore.models { public class songs { public int songsid { get; set; } public int albumsid { get; set; } public albums albums { get; set; } public artist artist { get; set; } public string songname { get; set; } public string genre { get; set; } public datetime releasedate { get; set; } } }
and homecontroller code:
namespace musicstore.controllers { public class homecontroller : controller { private musicstorecontext db = new musicstorecontext(); public actionresult index() { ienumerable<artist> artist = db.artists; ienumerable<songs> songs = db.songs; viewbag.listofartist = artist; viewbag.listofsongs = songs; return view(); }
Comments
Post a Comment