Understanding ASP.NET MVC?

This article is for the beginners who do not have much idea about MVC. As a beginner all you’ll be knowing is that MVC is a pattern but how do we develop applications using this MVC pattern.


So before understanding what MVC is lets understand first what ASP.NET is?

So ASP.NET is a framework which creates web pages and web sites with the help of html, css, and javascript and severs script.

ASP.NET supports 3 development models:

  1. Web Pages
  2. MVC
  3. Web Form


MVC (Model View Controller):

MVC is one of the development models of ASP.NET.

  • The Model represents the data of application (database records)
  • The View displays the data
  • The controller handles the flow of data

MVC Model defines application within 3 logic layers.

  • Input logic(Controller handles Input Logic)
  • Business Logic(Model  handles logic of application data)
  • UI Logic(View display the application data)



I.            This part of application manages data of the application or state of data, i.e. basically model object retrieves data from database.

II.            There is no fixed size or shape of model object because data of one application may not be same as other application.

III.            It includes Validation logic, business logic  and data access logic of an application

E.g. Student object (Model) might retrieves information from database, do some operation on it, validate it and then update information back to Student table in database.



This part of application controls the flow of application data. Basically it reads from a view, control user input and sends data to model.



This part of application display the data, basically it creates UI for data from model and display the data

E.g.: Edit View for Student table that displays textboxes, dropdown list and checkbox on the current state of a Student object.


I.            MVC helps in managing complex task by focusing on one aspect at time, a developer can work on model without depending on views or controller.

II.            Separating the view from rest of application logic enables changing of view technology in future without affecting the rest of the application.

E.g. Client might want view in Silverlight or HTML5


MVC vs Traditional Web Form:

I.            It is lighter than Web from because it does not use view state or server based forms or server controls.

II.            It provides better support for test-driven development (TDD)

III.            It has integrated with all existing Asp.net features like Routing, Master Page, Security and Authentication.

So I hope this article has given you a brief idea about what exactly ASP.NET MVC is…..

How to use grid for sorting and paging in MVC

This post will give you a clear picture of how sorting and paging is done to grid in MVC 3.

So you can now go ahead and provide paging and sorting options for the Grid in MVC 3, Just follow these below steps.

The Web Grid is the new (And easy) way to show data in views with paging, sorting, alternated lines and etc.

In this post you will learn how to use this new feature and what are its benefits.

What is the Web Grid?

The Web Grid is a helper that was included on the new Beta 1 version of ASP.NET MVC 3 (Changes can happens since it is a beta version) that enable us to show data easily.

This is a simple example of how data is rendered from model and binded to web grid


The Model

For the purpose of this article, we will be using a simple model with a few properties.

public class FavouriteGivenName


public string Name { get; set; }

public int Age { get; set; }

public string Address { get; set; }

public string City { get; set; }


We will create a list of items that we can show on the grid:

var mostPopular = new List<FavouriteGivenName>()


new FavouriteGivenName() {Name = “David”, Age = 30,                Address=”Paradise”,City=”Hyderabad”},

new FavouriteGivenName() {Name = “Suresh”, Age = 40 ,Address=”Dwarakanagar”, City=”Vizag”},

new FavouriteGivenName() {Name = “Mujafar”, Age = 17, Address=”Madhapur”, City=”Hyderabad”},

new FavouriteGivenName() {Name = “Karthik”, Age = 56, Address=”RTCX Road”, City=”Delhi”},

new FavouriteGivenName() {Name = “Chandu”, Age = 25, Address=”T-Nagar”, City=”Chennai”},

new FavouriteGivenName() {Name = “Bardwaj”, Age = 42,Address=”Gurdwar”, City=”Chandighar”},

new FavouriteGivenName() {Name = “Joshua”, Age = 63, Address=”Kodambakkam”, City=”Chennai”},

new FavouriteGivenName() {Name = “Dharahash”, Age = 15,Address=”MVPColonoy”,City=”Vizag”},

new FavouriteGivenName() {Name = “Pramod”, Age = 73, Address=”SanajeevGarden”, City=”Mumbai”},

new FavouriteGivenName() {Name = “George”, Age = 63,  Address=”NearRlystation”,City=”Guntur”}


Now that we have the model ready with a few records, we can work on showing the data on the grid.




<style type=”text/css”>

.webGrid { margin: 4px; border-collapse: collapse; width: 300px; }

.header { background-color: #E8E8E8; font-weight: bold; color: #FFF; }

.webGrid th, .webGrid td { border: 1px solid #C0C0C0; padding: 5px; }

.alt { background-color: #E8E8E8; color: #000; }

.person { width: 200px; font-weight:bold;}





var grid = new WebGrid(Model, canPage: true, rowsPerPage: 5);


@grid.GetHtml(tableStyle: “webGrid”,

headerStyle: “header”,

alternatingRowStyle: “alt”,

columns: grid.Columns(

grid.Column(“Name”, “Person Name”, canSort: true, format:@<b>@item.Name</b>, style: “person”),

grid.Column(“Age”, “Age”, canSort: true),

grid.Column(“Address”, “Address”, canSort: true),

grid.Column(“City”, “City Name”, canSort: true)





Clear and Simple right…