Click here to Skip to main content
15,901,373 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi Frnds,

I want to blink the text in Gridview , if the date is greater than todays date.

Note: blink the cell if the date is greater than todays date.


Please help me, give me a wonderful solution for this,

Thanks.
Posted

Try this
C#
void GridView_RowDataBound(Object sender, GridViewRowEventArgs e)
  {

    if(e.Row.RowType == DataControlRowType.DataRow)
    {
      // cell[]  postion of column Date
     if( Convert.Todatetime(e.Row.Cells[1].Text) > Datetime.Now())
      {
       e.Row.Style.Add("text-decoration","blink");
      }
    
    }

  }
 
Share this answer
 
Comments
Ranjith Reddy CSE 18-Jul-12 3:09am    
Please tell me, where to write your code. with in my code.
Ranjith Reddy CSE 18-Jul-12 3:09am    
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{

e.Row.Attributes.Add("onmouseover",
"this.originalcolor=this.style.backgroundColor;" + " this.style.backgroundColor='#FDCB0A';");

e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=this.originalcolor;")
}
pradiprenushe 18-Jul-12 5:22am    
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { e.Row.Attributes.Add("onmouseover", "this.originalcolor=this.style.backgroundColor;" + " this.style.backgroundColor='#FDCB0A';"); e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=this.originalcolor;");
// cell[] postion of column Date
if( Convert.Todatetime(e.Row.Cells[1].Text) > Datetime.Now())
{
e.Row.Style.Add("text-decoration","blink");
}
}
So, Sir, this is my code, where to write your code....in this code am confuse.


C#
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
   {
       if (e.Row.RowType == DataControlRowType.DataRow)
       {

           e.Row.Attributes.Add("onmouseover",
           "this.originalcolor=this.style.backgroundColor;" + " this.style.backgroundColor='#FDCB0A';");

           e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=this.originalcolor;")
       }




Please help.

Thanks
 
Share this answer
 
hi ,

public void GridView1_RowDataBound(Object sender, GridViewRowEventArgs e)
{

if (e.Row.RowType == DataControlRowType.DataRow)
{
// cell[] postion of column Date
if (Convert.ToDateTime(e.Row.Cells[3].Text) > DateTime.Now)
{
e.Row.Style.Add("text-decoration", "blink");
e.Row.Style.Add("color", "red");
}

}

}


i have just applied to my application it works perfetct.

kkakadiya
 
Share this answer
 
Comments
Ranjith Reddy CSE 18-Jul-12 3:38am    
No not working boss
Ranjith Reddy CSE 18-Jul-12 4:09am    
The name 'Datetime' does not exist in the current context
Hi,
Instead of this:
C#
e.Row.Attributes.Add("onmouseover",            "this.originalcolor=this.style.backgroundColor;" + " this.style.backgroundColor='#FDCB0A';");

e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=this.originalcolor;")


Try this:
C#
if( Convert.ToDateTime(e.Row.Cells[1].Text) > Datetime.Now())
{
    e.Row.Style.Add("text-decoration","blink");
    e.Row.Attributes.Add("onmouseover", "this.originalcolor=this.style.backgroundColor;" + " this.style.backgroundColor='#FDCB0A';"); 
    e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=this.originalcolor;")
}


--Amit
 
Share this answer
 
v2
Comments
Ranjith Reddy CSE 18-Jul-12 3:23am    
Boss , i want to change the row color, if Mouse over in GRIDVIEW and also I need Blinking cell if the date is greater than todays date.
Ranjith Reddy CSE 18-Jul-12 3:25am    
This is my error...........am working on asp.net c#

'System.Convert' does not contain a definition for 'Todatetime'
_Amy 18-Jul-12 3:29am    
See my updated answer. Sorry,instead of ToDateTime I'hv written Todatetime.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900