Telerik Mvc Grid Extension Method to highlight grid row

Telerik Mvc Grid Extension Method to highlight InActive record

I was recently working on a project where in there was a requirement that all those grid rows which are inactive in database should be highlighted with a different colour. In this project we were working with Telerik Mvc extensions.

I googled for this, and most of the responses were like, to add a client side RowDataBound event to each of the grid & place the logic there.

According to me this is a bit of time consuming tasks. So after some research & a bit help from telerik MVC forums, I created my own extension method to highlight the grid row for which the column value of the IsActive column is false.

In our database, each of the table contains a column “IsActive” which stores a Boolean value “true” or “false” so as to represent the particular record is Active or not. A record with false value in “IsActive” column indicates that the record is InActive.

Here are some simple steps to achieve this.

  1. First we need to write an extension method which will add a handler to highlight the record. Here is the code snippet for that

2. Add following class to CSS

3. Add following javascript function to your master page

4. Append your grid like this

And that’s all we need to do the row will be highlighted like this

You can find the source code here

Advertisements

Upgrade Application from Asp.Net MVC2 to MVC3

Upgrade Application from Asp.Net MVC2 to MVC3

It’s been a much long after MVC3 is been released & now it is much stable. So while working on a project, I need to upgrade my ASP.Net MVC 2 project to MVC 3.

ASP.Net MVC 3 can be installed side by side ASP.Net MVC 2 on you PC, which gives you flexibility in choosing when to upgrade an MVC2 application to MVC3. It is been very easy to upgrade the project to MVC3. We just need to follow following steps

  • Remove all references of System.Web.Mvc from each project in solution.
  • Now add a reference for System.Web.Mvc 3.0 to each of the project in the solution.
  • Also add a reference of System.Web.Helpers 2.0 to web project.
  • Also add a reference of System.Web.WebPages 2.0 to web project.
  • Go to views folder & open the Web.Config file & replace Version = 2.0.0.0 with version 3.0.0.0
  • Also add following code  to this Web.Config

  • Open the root Web.Config file & replace all references of “System.Web.Mvc 2.0.0.0” with “System.Web.Mvc 3.0.0.0”.
  • Now in appSettings add following keys

  • Now we need to make sure our system.web->pages->namespaces tag contains following entries

  • In the system.web->compilation->assemblies we should have following entries

  • Finally under the configuration -> runtime section put following code

  • And lastly add following javascript on your master pages, you need to add this javascript file to Scripts folder.  We need to get this file from any asp.net mvc3 project & paste it in the scripts folder. Also it is recommended you replace the old javascript files such as MicrosoftAjax.js, MicrosoftMvcAjax.js & MicrosoftMvcValidation.js.

Yuhu……………! Here we are. Now just compile & run your code. Now it will run on MVC3. Also we need to make sure we are targeting .net Framework 4.0 while upgrading the MVC2 application to MVC3.

Also there is a tool available to upgrade the MVC2 to MVC3. Here is a link to the tool

http://weblogs.asp.net/leftslipper/archive/2010/07/28/migrating-asp-net-mvc-2-applications-to-asp-net-mvc-3-preview-1.aspx

Cheers…..!

You can find the source code here.