title: gridview row blinking based on some conditions
body: <p>I have this gridview which in which I want certain rows to blink based on some conditions.
  I have tried javascript and jquery but nothing worked.</p>
  
  <p><a href="http://forums.asp.net/p/1375904/3287108.aspx" rel="nofollow">javasccript example</a></p>
  
  <p><a href="http://www.aspmemo.net/2012/03/gridview-rows-blink-using-jquery-in.html" rel="nofollow">jquery</a></p>
  
  <p>I tried jquery in above link but it is giving me error </p>
  
  <blockquote>
    <p>0x800a1391 - JavaScript runtime error: '$' is undefined</p>
  </blockquote>
  
  <p>I actually want to use it coz it matches my current requirement.
  My current requirement has that, rows which satisfies 3 set of conditions should blink</p>
  
  <pre><code>&lt;style type="text/css"&gt;
      .bgRow
      {
          background-color: white;
      }
      .norRow
      {
          background-color: Silver;
      }
  &lt;/style&gt;
  &lt;script src="~/Scripts/jquery-1.8.2.js"&gt;&lt;/script&gt;
      &lt;script src="yourUrl/jquery-1.4.1.min.js" type="text/javascript"&gt;&lt;/script&gt;
      &lt;script type="text/javascript"&gt;
          function setBG(GridAlarm)
          {
          var id = "#" + GridAlarm;
          $(id).find("tr").each(function ()//error comes here while debuggigng
          {
              var css = $(this).attr("class");
              if (css != null &amp;&amp; css == "bgRow")
                  $(this).addClass("norRow").removeClass("bgRow");
              else if (css != null &amp;&amp; css == "norRow")
                  $(this).addClass("bgRow").removeClass("norRow");
  
          });
          setTimeout("setBG('" + GridAlarm + "')", 1000); //1000 is equal to one second and call function every one second.
      }
  &lt;/script&gt;
  </code></pre>
  
  <p>the gridview code in design</p>
  
  <pre><code>&lt;asp:GridView ID="GridAlarm" CssClass="bgRow" EmptyDataText="NoData" CellPadding="7" CellSpacing="1" runat="server" DataKeyNames="id" AutoGenerateColumns="false" ShowHeader="true" OnRowDataBound="GridAlarm_RowDataBound" OnPageIndexChanging="GridAlarm_PageIndexChanging"&gt;
      &lt;Columns&gt;
          &lt;asp:BoundField DataField="TagName" HeaderText="TagName" /&gt;
          &lt;asp:BoundField DataField="Description" HeaderText="Description" /&gt;
          &lt;asp:BoundField DataField="Value" HeaderText="Value"  /&gt;
          &lt;asp:BoundField DataField="AlarmStatus" HeaderText="Alarm Status"/&gt;
          &lt;asp:BoundField DataField="AlarmRaisedDateTime" HeaderText="Alarm Raised"  /&gt;
          &lt;asp:BoundField DataField="AlarmClearedDateTime" HeaderText="Alarm Cleared"  /&gt;
          &lt;asp:BoundField DataField="AlarmAckDateTime" HeaderText="Alarm Acknowledgement"  /&gt;
          &lt;asp:TemplateField HeaderText="Select"&gt;
            &lt;ItemTemplate&gt;
                &lt;asp:CheckBox ID="chk_delete" runat="server" /&gt;
            &lt;/ItemTemplate&gt;
           &lt;/asp:TemplateField&gt;
      &lt;/Columns&gt;
  &lt;/asp:GridView&gt;
  </code></pre>
  
  <p>and below code behind</p>
  
  <pre><code>protected void GridAlarm_RowDataBound(object sender, GridViewRowEventArgs e)
  {
      if (e.Row.RowType == DataControlRowType.DataRow)
      {
          alarmStat = (e.Row.Cells[3].Text);
          ClearDate = (e.Row.Cells[5].Text);
          AckDate = (e.Row.Cells[6].Text);
  
          foreach (TableCell cell in e.Row.Cells)
          {
              if (alarmStat.Equals(System.Configuration.ConfigurationManager.AppSettings["A_Clear"].ToString()))
              {
                  cell.BackColor = System.Drawing.Color.Green;
                  cell.ForeColor = System.Drawing.Color.White;
              }
              else if (alarmStat.Equals(System.Configuration.ConfigurationManager.AppSettings["A_Raise"].ToString()))
              {
                  if (!string.IsNullOrEmpty(AckDate) &amp;&amp; (string.IsNullOrEmpty(ClearDate)))
                  {
                      cell.BackColor = System.Drawing.Color.Red;
          cell.ForeColor = System.Drawing.Color.White;
                  }
                  else if (string.IsNullOrEmpty(AckDate) &amp;&amp; (string.IsNullOrEmpty(ClearDate)))
                  {
                      e.Row.CssClass = "bgRow";
                  }
              }
          }
      }
  }
  </code></pre>
  
  <p>i also had to add following in page load</p>
  
  <pre><code>ClientScript.RegisterStartupScript(GetType(), "BG", "setBG('" + GridAlarm.ClientID + "')", true);
  </code></pre>
  
  <p>But it gives error as mentioned above..</p>
  
  <p>As for the conditions required for the gridview rows to blink you can see in code itself that is it should blink when status is Raised and AckDate and ClearDate are null or empty..
  Status,AckDate,ClearDate are present as columns in grid as you can see in code.</p>
  
  <p>What is wrong in above code?
  Is there any other way I can solve this problem?</p>