error Handles clause requires a WithEvents variable.

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


<asp:DataGrid
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"
 
K

Kevin Spencer

Did you declare "Grid" WithEvents?

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
 
M

Moe Sizlak

Hi Kevin,

Can you give me an example?

Moe

Kevin Spencer said:
Did you declare "Grid" WithEvents?

--
HTH,
Kevin Spencer
.Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

am
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,813
Latest member
lawrwtwinkle111

Latest Threads

Top