Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > error Handles clause requires a WithEvents variable.

Reply
Thread Tools

error Handles clause requires a WithEvents variable.

 
 
Moe Sizlak
Guest
Posts: n/a
 
      07-26-2004
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"


 
Reply With Quote
 
 
 
 
Kevin Spencer
Guest
Posts: n/a
 
      07-26-2004
Did you declare "Grid" WithEvents?

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

"Moe Sizlak" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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"
>
>



 
Reply With Quote
 
 
 
 
Moe Sizlak
Guest
Posts: n/a
 
      07-27-2004
Hi Kevin,

Can you give me an example?

Moe

"Kevin Spencer" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Did you declare "Grid" WithEvents?
>
> --
> HTH,
> Kevin Spencer
> .Net Developer
> Microsoft MVP
> Big things are made up
> of lots of little things.
>
> "Moe Sizlak" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > 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"
> >
> >

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Handles clause requires a WithEvents variable dancer ASP .Net 2 07-13-2007 02:40 PM
Question about file handles and windows handles @ Windows Operating Systems eino Python 1 05-08-2007 09:14 PM
error handles clause requires With Events Variable Sean ASP .Net 3 06-11-2004 02:23 PM
WithEvents ??? ASP .Net 4 12-24-2003 06:40 PM
Difference between "Protected WithEvents myClassName" And "Protected myClassName" ? Andreas Klemt ASP .Net 2 07-05-2003 12:51 AM



Advertisments