Click here to Skip to main content
13,247,816 members (61,356 online)
Click here to Skip to main content
Add your own
alternative version


10 bookmarked
Posted 20 Mar 2013

Priority Grid, an Application with ASP.NET MVC 4

, 20 Mar 2013
Rate this:
Please Sign up or sign in to vote.
A solution for creating a priority grid


This tip contains a solution for creating a priority grid. There are scenarios when you use a grid in your application for a specific purpose. For example, you need a grid to increase or decrease the priority of the individual selected row. In that case, you don’t need to deploy a feature heavy grid. The priority grid, as the name indicates, should be sufficient for such limited purpose use. The application uses MVC / JSON with LINQ to handle the data access in the grid.


The ASP.NET MVC Framework's Model View Controller pattern is increasingly growing in popularity for enabling users to build flexible, easily tested Web applications. A MVC application is also easy to maintain compared to web form application. Such an application would keep the main application code separate from persistence logic as well as from the front end view.

Using the Code

In our sample application, we use a repository (class) that performs the Linq query to retrieve the data from the input XML (note that we are using an XML file to populate the data in the grid). The MVC controller instantiates and calls the repository method to get the data. That way, any other controller that needs the same data can use the same repository without duplicating the code. We use separate classes within the model to pass data between controller and repository. To run the application, open the Visual Studio 2012 project and start. The application uses MVC ViewData; the ViewData (named ‘data’) is populated by LINQ call to the input XML and the returned ‘data’ is passed on to the front end jQuery html() method.

The increment priority method uses the following code:

var item1 = data[ind];
var item2= data[ind-1];

The grid is refreshed after the current row is swapped with the previous as shown above. The Save method uses the code below:

var myiD = Array();
    	$.each(data, function (index, value) {

It then makes an AJAX request with jQuery and JSON to the MVC controller to update the priority (of the rows) in the XML.

Points of Interest

jQuery with LINQ has recently received a huge surge of interest of the ASP.NET MVC. I wanted to create an example where I would invoke an AJAX call to dynamically populate a grid with the additional functionality of increasing (or decreasing) the priority of the selected row. I've been impressed not only with how few lines of JavaScript it takes me to get things done, but also how (relatively) easy it was to learn. This application works for small or short-lived applications, but can also be extended for large applications.


  • 19th March, 2013: Initial version


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Software Developer (Senior)
United States United States
I am passionate on coding and application development specially in the .NET C# windows and web platform.

You may also be interested in...


Comments and Discussions

-- There are no messages in this forum --
Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.171114.1 | Last Updated 20 Mar 2013
Article Copyright 2013 by Ankurkumarbora
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid