This question is locked. New answers and comments are not allowed.
Hello all,
I have my data returned as IQueryable<T>, resides inside a ViewModel class, when I view the page, nothing got displayed inside the GridView, the code outside the GridView displays the same data just fine. Here are my codes:
SongViewModel.cs:
My SongController.cs to populate the model:
My View:
In my foreach loop, I was able to access the "song" object, and display the SongTitle just fine.
Inside Telerik().Grid(), I've tried to add new column but intellisense won't work, and when I run the code as shown above, nothing got displayed.
Any idea where my problem might be? Thank you very much,
Kenny.
I have my data returned as IQueryable<T>, resides inside a ViewModel class, when I view the page, nothing got displayed inside the GridView, the code outside the GridView displays the same data just fine. Here are my codes:
SongViewModel.cs:
| public class SongViewModel |
| { |
| public NewestSongsModel NewestSongsModel { get; set; } |
| public FeaturedSongsModel FeaturedSongsModel { get; set; } |
| } |
| public class NewestSongsModel |
| { |
| public IQueryable<Song> NewestSongs { get; set; } |
| } |
| public class FeaturedSongsModel |
| { |
| public IQueryable<Song> FeaturedSongs { get; set; } |
| } |
My SongController.cs to populate the model:
| var model = new SongViewModel |
| { |
| NewestSongsModel = new NewestSongsModel { NewestSongs = sr.RetrieveLatestSongs(5) }, |
| FeaturedSongsModel = new FeaturedSongsModel { FeaturedSongs = sr.RetrieveFeaturedSongs(5) } |
| }; |
| return View(model); |
My View:
| <%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<NotesnhacWeb.Models.SongViewModel>" %> |
| <h2> |
| NEWEST SONGS</h2> |
| <% foreach (var song in Model.NewestSongsModel.NewestSongs) |
| {%> |
| <li> |
| <%= song.SongTitle%></li> |
| <% } %> |
| <h2> |
| FEATURED SONGS</h2> |
| <% foreach (var song in Model.FeaturedSongsModel.FeaturedSongs) |
| { %> |
| <li> |
| <%= song.SongTitle%></li> |
| <%} %> |
| <%= Html.Telerik().Grid(Model.FeaturedSongsModel.FeaturedSongs) |
| .Name("FeaturedSongs") .Render() |
| %> |
In my foreach loop, I was able to access the "song" object, and display the SongTitle just fine.
Inside Telerik().Grid(), I've tried to add new column but intellisense won't work, and when I run the code as shown above, nothing got displayed.
Any idea where my problem might be? Thank you very much,
Kenny.