Hi all,
The following code works fine.
If i remove the try statement, i recieve a generic is null exception when
trying to retrieve a datagrids data item.
With the try those exceptions are obviously caught, but it is clear the data
item is accessible otherwise as i am able to use its value.
I am just wondering (without the try statement) what the function could be
encountering to set of the null exception error.
Any thoughts?
Adam
Sub dgAnswerOptions _ItemDataBound( ByVal sender As Object, ByVal e As
DataGridItemEve ntArgs)
'determine if current item is not a header or footer
If(e.Item.ItemT ype <> ListItemType.He ader Or e.Item.ItemType <>
ListItemType.Fo oter) Then
'add index to answer options
e.Item.Cells(0) .Controls.Add(N ew
LiteralControl( e.Item.ItemInde x + 1 & "."))
'determin if logged in user belongs to the director or admin
groups
If(Security.IsD irector() Or Security.IsAdmi n()) Then
Try
'determine if current option is a correct option
If(e.Item.DataI tem.Item(2) = 1) Then //error occurs
here without try
'change cell formatting to reflect a correct
answer
e.Item.Cells(1) .CssClass = "correct"
e.Item.Cells(1) .Text = e.Item.Cells(1) .Text & "
(Correct)"
End If
Catch
e.Item.Cells(1) .Controls.Add(N ew LiteralControl( "
Type: " & e.Item.ItemType ))
End Try
End If
End If
End Sub
The following code works fine.
If i remove the try statement, i recieve a generic is null exception when
trying to retrieve a datagrids data item.
With the try those exceptions are obviously caught, but it is clear the data
item is accessible otherwise as i am able to use its value.
I am just wondering (without the try statement) what the function could be
encountering to set of the null exception error.
Any thoughts?
Adam
Sub dgAnswerOptions _ItemDataBound( ByVal sender As Object, ByVal e As
DataGridItemEve ntArgs)
'determine if current item is not a header or footer
If(e.Item.ItemT ype <> ListItemType.He ader Or e.Item.ItemType <>
ListItemType.Fo oter) Then
'add index to answer options
e.Item.Cells(0) .Controls.Add(N ew
LiteralControl( e.Item.ItemInde x + 1 & "."))
'determin if logged in user belongs to the director or admin
groups
If(Security.IsD irector() Or Security.IsAdmi n()) Then
Try
'determine if current option is a correct option
If(e.Item.DataI tem.Item(2) = 1) Then //error occurs
here without try
'change cell formatting to reflect a correct
answer
e.Item.Cells(1) .CssClass = "correct"
e.Item.Cells(1) .Text = e.Item.Cells(1) .Text & "
(Correct)"
End If
Catch
e.Item.Cells(1) .Controls.Add(N ew LiteralControl( "
Type: " & e.Item.ItemType ))
End Try
End If
End If
End Sub
Comment