Friday 7 December 2012

Bind WebGrid in Asp.net MVC


I just learn how to bind grid in MVC. I hope you guys just know basic about MVC.
First of all You guys just have to install one package.for that got to Tools->Library Package Manager
and run command in output window
Command:- Install-Package RazorGenerator.Templating

1.) Below is controller code.
in above code i just create simple List of my model.you can also get that list from database also.

2.) Below is model code.


in above code simple properties are created.

3.) Below is view code.







Here is your view code. here one thing is that you have to take care is that is first line.i tried with @model MvcApplication1.Models.NiksModel but it means it accept model from controller.but here we are passing list from controller so you just have defined as list of your model.

Reference:
http://www.dotnetcurry.com/ShowArticle.aspx?ID=618


No comments:

Post a Comment