Solved

Blink Gridview Row  Color - Utilizing J-Query

Posted on 2013-11-18
4
623 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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Article by: Najam
Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

744 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now