You are on page 1of 1

PrivateSub dgContacts_ItemDataBound(ByVal sender AsObject, ByVal e As

System.Web.UI.WebControls.DataGridItemEventArgs) Handles dgContacts.ItemDataBound


' Make sure that this is a data row and not a header or footer.
If e.Item.ItemType = ListItemType.ItemOrElse e.Item.ItemType =
ListItemType.AlternatingItem Then
' Get the value of the manager field.
Dim isManager AsString = CType(DataBinder.Eval(e.Item.DataItem, "Manager"),
String)

If isManager = "1"Then
' Set the text and background color.
e.Item.Cells(2).Text = "Manager"
e.Item.BackColor = System.Drawing.Color.AliceBlue
Else
' Set the text only.
e.Item.Cells(2).Text = "Employee"
EndIf
EndIf
EndSub

==================================================================================
===========

for each oItem as DataGridItem in DataGrid1.Items


oLabel = CType(oItem.FindControl("SessionID"),Label)
oLabel.ForeColor = System.Drawing.Color.Orange
next

You might also like