• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 3729
  • Last Modified:

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
0
BOEING39
Asked:
BOEING39
  • 5
  • 5
1 Solution
 
informaniacCommented:
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");
0
 
Rajar AhmedConsultantCommented:
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
0
 
BOEING39Author Commented:
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
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
Rajar AhmedConsultantCommented:
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

0
 
BOEING39Author Commented:
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)
    {

    }

}
0
 
Rajar AhmedConsultantCommented:
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 .
0
 
BOEING39Author Commented:
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.
0
 
Rajar AhmedConsultantCommented:
change these Codes .
Step1:Codebehind
 if (e.Row.Cells[15].Text == "MCO" || e.Row.Cells[15].Text == "MMCO")
            {
                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

Step 2 : On Aspx : Remove or Comment old script . Add Jquery Lib and add new script given below
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js" type="text/javascript"></script>
<script>
/* Remove this or remove this function - Starts
  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;
Comment this or remove this function 
*/

function blink() {
        var blink = document.all.tags("FONT");
        for (var i = 0; i < blink.length; i++) {
            if (blink[i].className = 'jqueryBlink') {
                blink[i].parentNode.parentNode.className = blink[i].parentNode.parentNode.className == "blinkCss" ? "altblinkCss" : "blinkCss";
            }
        }
    }
    $(document).ready(function () {
        setInterval(blink, 1000);
    });

</script>

Open in new window

Step 3: on Aspx add this css class
<style type="text/css">
.blinkCss
{
  background-color:Orange;   
}
.blinkCss font
{
  color:Black;     
    }
.altblinkCss
{
  background-color:red;
  
}
.altblinkCss font
{
  color:white;      
}

</style>

Open in new window


Hope this helps u.
0
 
BOEING39Author Commented:
Works great.   Thx so much for your assistance.    It's been a please
0
 
BOEING39Author Commented:
Excellant response time with accurate information easy to understand.   Thx so much.
0
 
Rajar AhmedConsultantCommented:
Thank u for the grade and appreciation .
Meeran03
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 5
  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now