D
djc
How do I get to the underlying data in a databound datagrid control? I have
tried several different things all with no luck. I know you should be able
to get to the data.... how exactly? The following is the last thing I tried
and I get this error: "Name 'Container' is not declared". Another thing I
tried is like below only I used e.DataItem instead of Container.DataItem and
in that case I got an error indicating that 'DataItem' was not a valid
property of 'e', or something to that effect.
Sub OnItemDataBound_Handler(sender As Object, e As DataGridItemEventArgs)
Dim itemType As ListItemType = e.Item.ItemType
If itemType = ListItemType.Item Or itemType =
ListItemType.AlternatingItem Then
If Not DataBinder.Eval(Container.DataItem,
"EstimatedDeliveryDate") Is DbNull.Value Then
Dim TheETA As DateTime =
DateValue(DataBinder.Eval(Container.DataItem("EstimatedDeliveryDate")))
Dim TheStatus As String =
DataBinder.Eval(Container.DataItem("Status")).ToString()
If (TheETA < Today) And (TheStatus = "In Progress") Then
e.Item.Cells(4).CssClass = "ETAColumnStyle_Overdue"
End If
End If
End If
End Sub
any help would be greatly appreciated.
thanks.
tried several different things all with no luck. I know you should be able
to get to the data.... how exactly? The following is the last thing I tried
and I get this error: "Name 'Container' is not declared". Another thing I
tried is like below only I used e.DataItem instead of Container.DataItem and
in that case I got an error indicating that 'DataItem' was not a valid
property of 'e', or something to that effect.
Sub OnItemDataBound_Handler(sender As Object, e As DataGridItemEventArgs)
Dim itemType As ListItemType = e.Item.ItemType
If itemType = ListItemType.Item Or itemType =
ListItemType.AlternatingItem Then
If Not DataBinder.Eval(Container.DataItem,
"EstimatedDeliveryDate") Is DbNull.Value Then
Dim TheETA As DateTime =
DateValue(DataBinder.Eval(Container.DataItem("EstimatedDeliveryDate")))
Dim TheStatus As String =
DataBinder.Eval(Container.DataItem("Status")).ToString()
If (TheETA < Today) And (TheStatus = "In Progress") Then
e.Item.Cells(4).CssClass = "ETAColumnStyle_Overdue"
End If
End If
End If
End Sub
any help would be greatly appreciated.
thanks.