Click here to Skip to main content
15,895,370 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i am setting status active and deactive in gridview using dropdownlist i want when user
set status active gridview row color became green and when user select deActive gridview roe color became red
i am using many code but no any code is working please help me
Posted

Try this..

If(DDL.SelectedItem.Text == "Active")
{
// callRowDataBound();
}

add this code in your databoundevent..
C#
if (e.Row.RowType == DataControlRowType.DataRow)
         {
             DateTime dtdate = DateTime.ParseExact(e.Row.Cells[1].Text, "dd/MM/yyyy", null);

             if (dtdate == DateTime.Now.Date)
             {
                 e.Row.BackColor = Color.FromName("#00B5D0");
             }
         }}
 
Share this answer
 
v2
try this gridview event:-

C#
protected void Gridview1_RowCommand(object sender, GridViewCommandEventArgs e)
   {
       if (e.Row.Cells[4].Text == "Active") //change your link button column index
        {
           e.Row.BackColor = ColorTranslator.FromHtml("#C2DAEC");
        }
      else
        {
              e.Row.BackColor = ColorTranslator.FromHtml("#ECE0C2");
        }
    }
 
Share this answer
 

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