Alternating colors in dynamic datagrid
-
How is it possible to alternate row colors in a dynamically created datagrid. Please help:rose::rose::rose::rose::rose::rose: A ding is a gind to a _W_H_A_T_ if a dong is a dang to a gand? -- modified at 8:46 Thursday 22nd December, 2005
You cannot specify the color for the alternating items using the
AlternatingItemStyle
property at runtime since you can only sepcify it at design time. To programmatically change the color of an item, you simply create an event handler for theItemCreated
event and change the color of the alternating item. The sample code looks like this:private void DataGrid1_ItemCreated(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
{
if(e.Item.ItemType == ListItemType.Item)
{
e.Item.BackColor = System.Drawing.Color.Blue;
}
else if(e.Item.ItemType == ListItemType.AlternatingItem)
{
e.Item.BackColor = System.Drawing.Color.Green;
}
}For more information, see DataGridItem Members[^]
-
You cannot specify the color for the alternating items using the
AlternatingItemStyle
property at runtime since you can only sepcify it at design time. To programmatically change the color of an item, you simply create an event handler for theItemCreated
event and change the color of the alternating item. The sample code looks like this:private void DataGrid1_ItemCreated(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
{
if(e.Item.ItemType == ListItemType.Item)
{
e.Item.BackColor = System.Drawing.Color.Blue;
}
else if(e.Item.ItemType == ListItemType.AlternatingItem)
{
e.Item.BackColor = System.Drawing.Color.Green;
}
}For more information, see DataGridItem Members[^]
-
How is it possible to alternate row colors in a dynamically created datagrid. Please help:rose::rose::rose::rose::rose::rose: A ding is a gind to a _W_H_A_T_ if a dong is a dang to a gand? -- modified at 8:46 Thursday 22nd December, 2005
You did'nt mantion Any condition in this Question you have to spacify programatically Thanks
Pavan Pareta