hi
u could use below function and call this function OnRowCreated=HighlightRow
in your grid view
protected void HighlightRow(Object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
//find your control here whether its a textbox or label
Label lblValoreSeriale= (Label)e.Row.FindControl("lblValoreSeriale");
if(lblValorSeriale != null)
{
ifConvert.ToInt32((lblValoreSeriale.Text) 50)
e.Row.BackColor = System.Drawing.Color.Aqua;
}
}
}
hope this helps
"kjqua" <kj***@pippo.itwrote in message
news:eZ**************@TK2MSFTNGP02.phx.gbl...
Hi all,
I am newbie in c# and i have a question regarding DataGridView
I have a Table with 3 Columns
(0)IdLeggiSeriale <Is Primary key>
(1)ValoreSeriale <Is Integer>
(2)DataAcquisizione <Is DateTime>
I will like to change the color of each row that
in the in column(1) "ValoreSeriale" the Value is greater than 50.
private void dataGridView1_CellFormatting(object sender,
DataGridViewCellFormattingEventArgs e)
{
if
(dataGridView1.Columns[e.ColumnIndex].Name.Equals("ValoreSeriale"))
{
Int32 intValue;
if (Int32.TryParse((String)e.Value, out intValue) &&
(intValue 50))
{
e.CellStyle.BackColor = Color.Yellow;
e.CellStyle.SelectionBackColor = Color.DarkRed;
}
}
}
In the Above code i only change the color a singular cell.
How can i change all the row.
Thanks
Marco