Sign In| Join
Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Mar 26, 2012 02:27 PM by BrockAllen
Participant
1128 Points
692 Posts
Mar 26, 2012 02:24 PM|LINK
Hi,
I have a action which returns List which i want to show in WebGrid.
public ActionResult Index() { ViewBag.Message = "Welcome to ASP.NET MVC!"; List<Person> lstPersons = new List<Person>() { new Person() { EmployeeID = "E101", PersonName = "Sanjay", WorkExperience = 10}, new Person() { EmployeeID = "E102", PersonName = "Nitesh", WorkExperience = 9}, new Person() { EmployeeID = "E103", PersonName = "Rajnikant", WorkExperience = 999}, new Person() { EmployeeID = "E104", PersonName = "Chandu", WorkExperience = 8}, }; ViewBag.Records = lstPersons; return View(); }
Now if i use Razor in CSHTML pageas shown below, I can see the grid with records:
<div> @{ var grid = new WebGrid(@ViewBag.Records); } @grid.GetHtml(); </div>
But if i use a Aspx Page, the grid is not coming. The code is as below:
<div> <% WebGrid wgrid = new WebGrid(ViewBag.Records); %> <% wgrid.GetHtml(); %> </div>
Can anybody let me know why aspx page is not rendering anything ??
Thanks in advance
All-Star
27554 Points
4912 Posts
MVP
Mar 26, 2012 02:27 PM|LINK
Change:
<% wgrid.GetHtml(); %> to
<%= wgrid.GetHtml() %>
SanjaySutar
Participant
1128 Points
692 Posts
Webgrid not rendering in aspx page
Mar 26, 2012 02:24 PM|LINK
Hi,
I have a action which returns List which i want to show in WebGrid.
public ActionResult Index() { ViewBag.Message = "Welcome to ASP.NET MVC!"; List<Person> lstPersons = new List<Person>() { new Person() { EmployeeID = "E101", PersonName = "Sanjay", WorkExperience = 10}, new Person() { EmployeeID = "E102", PersonName = "Nitesh", WorkExperience = 9}, new Person() { EmployeeID = "E103", PersonName = "Rajnikant", WorkExperience = 999}, new Person() { EmployeeID = "E104", PersonName = "Chandu", WorkExperience = 8}, }; ViewBag.Records = lstPersons; return View(); }<div> @{ var grid = new WebGrid(@ViewBag.Records); } @grid.GetHtml(); </div><div> <% WebGrid wgrid = new WebGrid(ViewBag.Records); %> <% wgrid.GetHtml(); %> </div>Thanks in advance
BrockAllen
All-Star
27554 Points
4912 Posts
MVP
Re: Webgrid not rendering in aspx page
Mar 26, 2012 02:27 PM|LINK
Change:
DevelopMentor | http://www.develop.com
thinktecture | http://www.thinktecture.com/