protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { e.Row.Attributes.Add("onclick", "this.originalstyle=this.style.backgroundColor;this.style.backgroundColor='#EEFF00'"); } }
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) { string FromName = Convert.ToString(System.Drawing.Color.Yellow); if (GridView1.SelectedRow != null) //not the first row selected { if (Session[GridView1.SelectedRow.RowIndex.ToString()] != null) //Session was set { GridView1.SelectedRow.BackColor = System.Drawing.Color.FromName(Session[GridView1.SelectedRow.RowIndex.ToString()].ToString()); } } }
GridView1.RowDataBound += new GridViewRowEventHandler(GridView1_RowDataBound); void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { int value = (int)DataBinder.Eval(e.Row.DataItem, e.Row.Cells[2].Text); // e.Row.Cells[2] references the cell value you want to use e.Row.Cells[2].BackColor = Color.FromName("#c6efce"); } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)