Link to home
Start Free TrialLog in
Avatar of BOEING39
BOEING39

asked on

GRIDVIEW CELL BLINKING BEHIND CODE

I have the following code example that I would like to insert into the attached code behind to make colum [2] blink based on the criteria in column [15] being either "MCO" or "MMCO".  The below code sniplet is an example for a timestamp.   Need assistance in applying to the attached code.


public void GridView1_RowDataBound(Object sender, GridViewRowEventArgs e)
 {
 
 if (e.Row.RowType == DataControlRowType.DataRow)
 {

 // cell[2] postion of column to BLINK, cell position based on criteria to BLINK = [15] when = "MCO" or "MMCO"

 if (Convert.ToDateTime(e.Row.Cells[3].Text) > DateTime.Now)
 {
 e.Row.Style.Add("text-decoration", "blink");
 e.Row.Style.Add("color", "red");
 }
 
 }
Home1All.aspx.cs
Avatar of Obadiah Christopher
Obadiah Christopher
Flag of India image

So what's the issue here?

Is this what you are looking for?

if (e.Row.Cells[15].Text == "MCO" || e.Row.Cells[15].Text == "MMCO")
            {
e.Row.Cells[2].Style.Add("text-decoration", "blink");
 e.Row.Cells[2].Style.Add("color", "red");
try this, have this script on your aspx page inorder to blink in IE.
//Cross browser function for blink process.
<script>
        function blink() {
            var blink = document.all.tags("BLINK");
            for (var i = 0; i < blink.length; i++)
                blink[i].style.visibility = blink[i].style.visibility == "" ? "hidden" : ""
        }

        function startBlink() {
            if (document.all)
                setInterval("blink()", 1000)
        }
        window.onload = startBlink;
    </script>

Open in new window

    protected void gvData_RowDataBound(object sender, GridViewRowEventArgs e)
    {

        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            if (e.Row.Cells[15].Text == "MCO" || e.Row.Cells[15].Text == "MMCO" )
            {
                e.Row.Cells[2].Text = "<blink>" + e.Row.Cells[0].Text.ToString() + "</blink>";
                e.Row.Cells[2].ForeColor = Color.Red;
                e.Row.BackColor = System.Drawing.Color.Yellow;
            }
        }

        
    }

Open in new window


Meeran03
Avatar of BOEING39
BOEING39

ASKER

I have the timer script inserted into the Head and added the code behind; however,  as the column associated with the blinking feature is actually 1 with the header MCO ORDER.
With the code modified as requested it still not blinking.
Home1All.aspx
Home1All.aspx.cs
Try this,
if (e.Row.RowType == DataControlRowType.DataRow){
            if (e.Row.Cells[15].Text == "AOG" || e.Row.Cells[15].Equals(DBNull.Value))
            {
                e.Row.BackColor = System.Drawing.Color.Red;
            }

            else if (e.Row.Cells[15].Text == "ETOPS - Working")
            {
                e.Row.BackColor = System.Drawing.Color.Yellow;
            }

            else if (e.Row.Cells[15].Text == "AOG - R/T")
            {
                e.Row.BackColor = System.Drawing.Color.Tomato;
            }

            else if (e.Row.Cells[15].Text == "High Priority")
            {

                e.Row.BackColor = System.Drawing.Color.LightSkyBlue;

            }
            else if (e.Row.Cells[15].Text == "SOS - Working")
            {

                e.Row.BackColor = System.Drawing.Color.Orange;

            }
            else if (e.Row.Cells[15].Text == "Working Spare")
            {

                e.Row.BackColor = System.Drawing.Color.Aquamarine;

            }
            else if (e.Row.Cells[15].Text == "AOG - Vendor")
            {

                e.Row.BackColor = System.Drawing.Color.Orange;

            }
            else if (e.Row.Cells[15].Text == "AOG-Sched/Work Required")
            {

                e.Row.BackColor = System.Drawing.Color.Crimson;
            }
            else if (e.Row.Cells[15].Text == "AOG-Sched/Work Elective")
            {

                e.Row.BackColor = System.Drawing.Color.Coral;
            }
            else if (e.Row.Cells[15].Text == "Alert ETOPS Fly Day")
            {

                e.Row.BackColor = System.Drawing.Color.Fuchsia;
            }
            else if (e.Row.Cells[15].Text == "Ready Spare")
            {

                e.Row.BackColor = System.Drawing.Color.Lime;
            }
            else if (e.Row.Cells[15].Text == "Ready Spare - A/C Hooked - WU-cw")
            {

                e.Row.BackColor = System.Drawing.Color.Lime;
            }
            else if (e.Row.Cells[15].Text == "Ready Spare - Needs WU ck")
            {

                e.Row.BackColor = System.Drawing.Color.Lime;
            }
            else if (e.Row.Cells[15].Text == "Ready Spare - A/C Hooked - Needs WU")
            {

                e.Row.BackColor = System.Drawing.Color.Lime;
            }
            else if (e.Row.Cells[15].Text == "Status Ready Spare - Needs WU-ck")
            {

                e.Row.BackColor = System.Drawing.Color.Lime;
            }
        if (e.Row.Cells[15].Text == "High Priority")
        {

            e.Row.Cells[15].ForeColor = Color.Red;

        }
        if (e.Row.Cells[15].Text == "Alert Requires Verification Flight")
        {

            e.Row.Cells[15].ForeColor = Color.White;
            e.Row.BackColor = System.Drawing.Color.DarkRed;
        }
        if (e.Row.Cells[15].Text == "Alert Domestic Ops Only - Non Etops")
        {

            e.Row.Cells[15].ForeColor = Color.Red;
            e.Row.BackColor = System.Drawing.Color.Gold;
        }
        if (e.Row.Cells[15].Text == "AOG Off Station Repairs")
        {

            e.Row.Cells[15].ForeColor = Color.Black;
            e.Row.BackColor = System.Drawing.Color.Yellow;
        }
        if (e.Row.Cells[15].Text == "AOG - SSE ATA Category Item")
        {

            e.Row.Cells[15].ForeColor = Color.Black;
            e.Row.BackColor = System.Drawing.Color.Pink;
        }
        if (e.Row.Cells[15].Text == "MMCO-Open")
        {

            e.Row.Cells[15].ForeColor = Color.Black;
            e.Row.BackColor = System.Drawing.Color.Yellow;
        }
        if (e.Row.Cells[15].Text == "MCO-Open")
        {

            e.Row.Cells[15].ForeColor = Color.Black;
            e.Row.BackColor = System.Drawing.Color.Yellow;
        }
        if (e.Row.Cells[15].Text == "Alert ETOPS Qualified")
        {

            e.Row.Cells[15].ForeColor = Color.Red;
            e.Row.BackColor = System.Drawing.Color.Gold;
        }


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

Open in new window

Changed accordingly still not working.


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

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

            else if (e.Row.Cells[15].Text == "ETOPS - Working")
            {
                e.Row.BackColor = System.Drawing.Color.Yellow;
            }

            else if (e.Row.Cells[15].Text == "AOG - R/T")
            {
                e.Row.BackColor = System.Drawing.Color.Tomato;
            }

            else if (e.Row.Cells[15].Text == "High Priority")
            {

                e.Row.BackColor = System.Drawing.Color.LightSkyBlue;

            }
            else if (e.Row.Cells[15].Text == "SOS - Working")
            {

                e.Row.BackColor = System.Drawing.Color.Orange;

            }
            else if (e.Row.Cells[15].Text == "Working Spare")
            {

                e.Row.BackColor = System.Drawing.Color.Aquamarine;

            }
            else if (e.Row.Cells[15].Text == "AOG - Vendor")
            {

                e.Row.BackColor = System.Drawing.Color.Orange;

            }
            else if (e.Row.Cells[15].Text == "AOG-Sched/Work Required")
            {

                e.Row.BackColor = System.Drawing.Color.Crimson;
            }
            else if (e.Row.Cells[15].Text == "AOG-Sched/Work Elective")
            {

                e.Row.BackColor = System.Drawing.Color.Coral;
            }
            else if (e.Row.Cells[15].Text == "Alert ETOPS Fly Day")
            {

                e.Row.BackColor = System.Drawing.Color.Fuchsia;
            }
            else if (e.Row.Cells[15].Text == "Ready Spare")
            {

                e.Row.BackColor = System.Drawing.Color.Lime;
            }
            else if (e.Row.Cells[15].Text == "Ready Spare - A/C Hooked - WU-cw")
            {

                e.Row.BackColor = System.Drawing.Color.Lime;
            }
            else if (e.Row.Cells[15].Text == "Ready Spare - Needs WU ck")
            {

                e.Row.BackColor = System.Drawing.Color.Lime;
            }
            else if (e.Row.Cells[15].Text == "Ready Spare - A/C Hooked - Needs WU")
            {

                e.Row.BackColor = System.Drawing.Color.Lime;
            }
            else if (e.Row.Cells[15].Text == "Status Ready Spare - Needs WU-ck")
            {

                e.Row.BackColor = System.Drawing.Color.Lime;
            }
        if (e.Row.Cells[15].Text == "High Priority")
        {

            e.Row.Cells[15].ForeColor = Color.Red;

        }
        if (e.Row.Cells[15].Text == "Alert Requires Verification Flight")
        {

            e.Row.Cells[15].ForeColor = Color.White;
            e.Row.BackColor = System.Drawing.Color.DarkRed;
        }
        if (e.Row.Cells[15].Text == "Alert Domestic Ops Only - Non Etops")
        {

            e.Row.Cells[15].ForeColor = Color.Red;
            e.Row.BackColor = System.Drawing.Color.Gold;
        }
        if (e.Row.Cells[15].Text == "AOG Off Station Repairs")
        {

            e.Row.Cells[15].ForeColor = Color.Black;
            e.Row.BackColor = System.Drawing.Color.Yellow;
        }
        if (e.Row.Cells[15].Text == "AOG - SSE ATA Category Item")
        {

            e.Row.Cells[15].ForeColor = Color.Black;
            e.Row.BackColor = System.Drawing.Color.Pink;
        }
        if (e.Row.Cells[15].Text == "MMCO-Open")
        {

            e.Row.Cells[15].ForeColor = Color.Black;
            e.Row.BackColor = System.Drawing.Color.Yellow;
        }
        if (e.Row.Cells[15].Text == "MCO-Open")
        {

            e.Row.Cells[15].ForeColor = Color.Black;
            e.Row.BackColor = System.Drawing.Color.Yellow;
        }
        if (e.Row.Cells[15].Text == "Alert ETOPS Qualified")
        {

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

    protected void Button2_Click(object sender, EventArgs e)
    {
        Response.Clear();
        Response.Buffer = true;

        Response.AddHeader("content-disposition",
                "attachment;filename=GridViewExport.doc");
        Response.Charset = "";
        Response.ContentType = "application/vnd.ms-word ";
        StringWriter sw = new StringWriter();
        HtmlTextWriter hw = new HtmlTextWriter(sw);
        GridView1.AllowPaging = false;
        GridView1.RenderControl(hw);
        Response.Output.Write(sw.ToString());
        Response.Flush();
        Response.End();
    }
    public override void VerifyRenderingInServerForm(Control control)
    {

    }

}
check whether your recieving MCO OR MMCO with upper case on cell15 do a debug and test whether its processing inside d loop of d above condition .
Ok I got it working.   It is not applying fore color of "Red" however.   Would it be difficult to make the entire background color Blink or alternate colors??   Trying to bring as much attention to this information as possible.
ASKER CERTIFIED SOLUTION
Avatar of Rajar Ahmed
Rajar Ahmed
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Works great.   Thx so much for your assistance.    It's been a please
Excellant response time with accurate information easy to understand.   Thx so much.
Thank u for the grade and appreciation .
Meeran03