M
Moe Sizlak
Hi,
I am trying to create an custom event to fill an image control, I keep
getting the error "Handles clause requires a WithEvents variable." What am I
missing?
Moe
Private Sub dg_details_ItemCreated(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.DataGridItemEventArgs) Handles Grid.ItemCreated
Dim img As New System.Web.UI.WebControls.Image
img = CType(e.Item.FindControl("image1"),
System.Web.UI.WebControls.Image)
Dim d As System.Data.Common.DbDataRecord
d = e.Item.DataItem
If Not d Is Nothing Then
If Not img Is Nothing Then
Dim strVal As String = "" ' field number in the list
If Not strVal Is Nothing AndAlso strVal <> "" Then
img.imageurl = strVal
else
img.imageurl = "SecondSpacer.gif"
End If
End If
End If
End Sub
<aspataGrid
ID="dg_details"
AutoGenerateColumns=False
Width="250"
HeaderStyle-BackColor="purple"
HeaderStyle-ForeColor="White"
HeaderStyle-HorizontalAlign="Center"
HeaderStyle-Font-Bold="True"
border="0"
OnItemCreated="dg_details_ItemCreated"
I am trying to create an custom event to fill an image control, I keep
getting the error "Handles clause requires a WithEvents variable." What am I
missing?
Moe
Private Sub dg_details_ItemCreated(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.DataGridItemEventArgs) Handles Grid.ItemCreated
Dim img As New System.Web.UI.WebControls.Image
img = CType(e.Item.FindControl("image1"),
System.Web.UI.WebControls.Image)
Dim d As System.Data.Common.DbDataRecord
d = e.Item.DataItem
If Not d Is Nothing Then
If Not img Is Nothing Then
Dim strVal As String = "" ' field number in the list
If Not strVal Is Nothing AndAlso strVal <> "" Then
img.imageurl = strVal
else
img.imageurl = "SecondSpacer.gif"
End If
End If
End If
End Sub
<aspataGrid
ID="dg_details"
AutoGenerateColumns=False
Width="250"
HeaderStyle-BackColor="purple"
HeaderStyle-ForeColor="White"
HeaderStyle-HorizontalAlign="Center"
HeaderStyle-Font-Bold="True"
border="0"
OnItemCreated="dg_details_ItemCreated"