Why won't my anonymous function fire on grid.prerender?
Posted
by adam0101
on Stack Overflow
See other posts from Stack Overflow
or by adam0101
Published on 2010-04-23T19:46:50Z
Indexed on
2010/04/24
2:53 UTC
Read the original article
Hit count: 343
In my gridview I have fields for inserting a new record in the footer.
In my objectdatasource selecting event if no records came back I bind a single mock row to force the footer to show so they can still add records. Since the row does not contain real data I hide the row.
...
If result.ItemCount = 0 Then
result = mockRow
AddHandler mygridview.PreRender, AddressOf HideRow
End If
End Sub
Private Sub HideRow(ByVal sender as Object, ByVal e as EventArgs)
mygridview.Rows(0).Visible = False
End Sub
This works fine. However, I'd like to condense it like this:
...
If result.ItemCount = 0 Then
result = mockRow
AddHandler mygridview.PreRender, Function() mygridview.Rows(0).Visible = False
End If
End Sub
This compiles fine, but the row doesn't get hidden. Can anyone tell me why my anonymous function isn't getting hit?
© Stack Overflow or respective owner