private void ClearBackColor() { foreach (GridViewRow row1 in GridView1.Rows) { row1.BackColor = System.Drawing.Color.White; } } protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e) { ClearBackColor(); GridView1.SelectedRow.BackColor = System.Drawing.Color.Yellow; } protected void GridView1_RowDataBound1(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { ImageButton l = (ImageButton)e.Row.FindControl("ImageButton1"); l.Attributes.Add("OnClick", "this.originalcolor=this.style.backgroundColor;" + " this.parentNode.parentNode.style.backgroundColor='red';" + "if (confirm('Are you sure you want to delete this record " + DataBinder.Eval(e.Row.DataItem, "UKC_LEDGER_CODE") + "'))return true;else {this.parentNode.parentN } }
private void myDataGridView_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e) { if (e.ColumnIndex == 1) { if (myDataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].Value == "abc") { //e.CellStyle.BackColor = Color.Yellow; e.CellStyle.ForeColor = Color.Red; } } if (e.ColumnIndex == 4) { var check = myDataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].Value; if (check != null && (bool)check == true) { e.CellStyle.BackColor = Color.Gray; e.CellStyle.ForeColor = Color.Red; } } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)