Part 2: How to Dynamically set row background color in a webgrid depending on the content in MVC4.

WebGrid is an most popular helper (control) for display tabular data with support for custom formatting of columns, paging, sorting and more in mvc application similar as gridview in asp.net webform application. Here I will explain all those things one by one, like Paging, filtering, sorting, custom formatting, display nested data, freezing webgrid header, freezing webgrid column, conditional formatting and lots more. 
Here I am going to explain Part 2: How to Dynamically set row background color in a webgrid depending on the content in MVC4.
In Part 1, I have explained How to display database data in webgrid in mvc 4.
Webgrid row background color depending on value
Serial No Username Full Name Email Is Active?
1
Kistna Kistna Martin martin@gmail.com
2
Mahari Mahari Thompson thompson@yahoo.in
Part 2: How to Dynamically set row background color in a webgrid depending on the content in MVC4.
 
<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="utf-8" />
        <title>@ViewBag.Title - My ASP.NET MVC Application</title>
        <link href="~/favicon.ico" rel="shortcut icon" type="image/x-icon" />
        <meta name="viewport" content="width=device-width" />
        @Styles.Render("~/Content/css")
        @Scripts.Render("~/bundles/modernizr")
    </head>
    <body>
        <header>
            <div class="content-wrapper">
                <div class="float-left">
                    <p class="site-title">@Html.ActionLink("your logo here", "Index", "Home")</p>
                </div>
                <div class="float-right">
                    <section id="login">
                        @Html.Partial("_LoginPartial")
                    </section>
                    <nav>
                        <ul id="menu">
                            <li>@Html.ActionLink("Home", "Index", "Home")</li>
                            <li>@Html.ActionLink("About", "About", "Home")</li>
                            <li>@Html.ActionLink("Contact", "Contact", "Home")</li>
                        </ul>
                    </nav>
                </div>
            </div>
        </header>
        <div id="body">
            @RenderSection("featured", required: false)
            <section class="content-wrapper main-content clear-fix">
                @RenderBody()
            </section>
        </div>
        <footer>
            <div class="content-wrapper">
                <div class="float-left">
                    <p>&copy; @DateTime.Now.Year - My ASP.NET MVC Application</p>
                </div>
            </div>
        </footer>

        @Scripts.Render("~/bundles/jquery")
        @RenderSection("scripts", required: false)
    </body>
</html>






Posted By :