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.
- 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
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
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 = 22.214.171.124 with version 126.96.36.199
- Also add following code to this Web.Config
- Open the root Web.Config file & replace all references of “System.Web.Mvc 188.8.131.52” with “System.Web.Mvc 184.108.40.206”.
- 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
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
You can find the source code here.