Solved

Blink Gridview Row  Color - Utilizing J-Query

Posted on 2013-11-18
4
635 Views
Last Modified: 2013-11-26
Please review the attached code.   I need to Blink the "Background" Color of the entire "Gridview" row based on the value of column [12] utilizing "JQuery".   I do not want to Blink the text only the background color.

public partial class BigBoardDisp : System.Web.UI.Page
{

    protected void GridView1_RowDataBound (object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
            if (e.Row.Cells[6].Text == "AOG" || e.Row.Cells[6].Equals(DBNull.Value))
            {
                e.Row.BackColor = System.Drawing.Color.Red;
            }

            else if (e.Row.Cells[6].Text == "RDY")
            {
                e.Row.BackColor = System.Drawing.Color.Aqua;
            }

            else if (e.Row.Cells[6].Text == "WKG")
            {
                e.Row.BackColor = System.Drawing.Color.LightSkyBlue;
            }

            else if (e.Row.Cells[6].Text == "INSP")
            {
                e.Row.BackColor = System.Drawing.Color.Yellow;
            }

            else if (e.Row.Cells[6].Text == "BOB")
            {
                e.Row.BackColor = System.Drawing.Color.Lime;
            }

            else if (e.Row.Cells[6].Text == "On-Time")
            {
                e.Row.BackColor = System.Drawing.Color.SpringGreen;
            }
            else if (e.Row.Cells[6].Text == "MX-Delay")
            {
                e.Row.BackColor = System.Drawing.Color.Crimson;
            }

            if (e.Row.Cells[6].Text == "AOG")
            {
            e.Row.Cells[6].Text = "<FONT class='jqueryBlink'>" + e.Row.Cells[6].Text + "</FONT>";

        }

    }

Open in new window

0
Comment
Question by:BOEING39
  • 2
  • 2
4 Comments
 
LVL 19

Expert Comment

by:Albert Van Halen
ID: 39660469
Instead of putting a font tag with class in the text property of the cell, I would add a class to the row. Perhaps you can use
e.Row.CssClass="jqueryBlink"

Open in new window

After that it's up to jquery to capture the tablerows having the class and start blinking.

I created a fiddle for you : http://jsfiddle.net/j79kR/
0
 

Author Comment

by:BOEING39
ID: 39664819
This blinks all the row alternately.   I need code similar to that above for flashing (text) that blinks only rows meeting specific criteria without using css.   In the above examples it is utilizing "FONT" class.

For examplethe following code flashes the hyperlink column cell red/yellow based on MMCO-Open.   What I am looking for is for the entire row to blink based on a similar condition.

if (e.Row.Cells[12].Text == "MCO-Open" || e.Row.Cells[12].Text == "MMCO-Open")
        {
            HyperLink lnkMCO = (HyperLink)e.Row.Cells[1].Controls[0];
            lnkMCO.Text = "<FONT class='jqueryBlink'>" + lnkMCO.Text.ToString() + "</FONT>";
            //lnkMCO.ForeColor = Color.Red;
            lnkMCO.Style.Add("text-decoration", "none");
            e.Row.BackColor = System.Drawing.Color.Yellow;

Open in new window

0
 
LVL 19

Accepted Solution

by:
Albert Van Halen earned 500 total points
ID: 39665183
In your code snippet you say that it blinks; it merely renders the rows' backgroundcolor to yellow.
If the table is updating via updatepanel it would indeed 'blink' after a partial postback. But then you don''t have to use jQuery because you render everything serverside.

I would suggest to use css rules to style the rows.

It's unclear to me what you want.
0
 

Author Closing Comment

by:BOEING39
ID: 39679656
Thanks
0

Featured Post

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Diagnostics with Net and Net.Sockets 2 27
Video Player 2017 5 21
How useful is the free version of Selenium? 3 34
EF5: Question about Metadata Artifact Processing 4 15
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question