Datagrid
-
-
Hello, I have column in my datagrid that I used a check box. This column contains a 1 or 0 when checked or not. How do I make the datagrid display different colors on that column based on a 1 or 0 in the database? Thanks for your help Commickey
You must use the Item_DataBound Event of the Grid. private void DataGrid1_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e) { if ( ( e.Item.ItemType == ListItemType.Item ) || ( e.Item.ItemType == ListItemType.AlternatingItem ) ) { int index = 23; if ( bool.Parse ( e.Item.Cells [ index ].Text ) ) e.Item.Cells [ index ].BackColor = Color.Red; else e.Item.Cells [ index ].BackColor = Color.Green; } } Try to copy this piece of code in your code behind.... Regards Ricardo Casquete