473,404 Members | 2,195 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

error Handles clause requires a WithEvents variable.

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"
Nov 18 '05 #1
2 3108
Did you declare "Grid" WithEvents?

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

"Moe Sizlak" <mo*@moe.com> wrote in message
news:uW**************@TK2MSFTNGP12.phx.gbl...
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"

Nov 18 '05 #2
Hi Kevin,

Can you give me an example?

Moe

"Kevin Spencer" <ks******@takempis.com> wrote in message
news:OB**************@TK2MSFTNGP12.phx.gbl...
Did you declare "Grid" WithEvents?

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

"Moe Sizlak" <mo*@moe.com> wrote in message
news:uW**************@TK2MSFTNGP12.phx.gbl...
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"


Nov 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Peter Frost | last post by:
Please help I don't know if this is possible but what I would really like to do is to use On Error Goto to capture the code that is being executed when an error occurs. Any help would be much...
11
by: Steve Hoyer | last post by:
I am trying to deploy my first asp.net app to our webserver (2K server, IIS 5) My start page comes up and you can get to the subsequent pages that are tied into our sql server (2K). Each page...
3
by: Sean | last post by:
HI There, I am trying to submit a form when a selection is made from a dropdown list, I keep getting the error "Handles clause requires With Events Variable". Could someone help me with the...
1
by: Shakthi | last post by:
Hi, Pls let me how to solve this error "Specified argument out of range" Pls find the code below and let me know the solution. Public Class viewcart Inherits System.Web.UI.Page Protected...
9
by: Remulac | last post by:
Hello, I'm trying to get the value out of a dropdown list box and assign it to a variable. When I click on the list box, I invoke this line of code. I get the error, "Object reference not set...
8
by: ST | last post by:
Hello everyone, Can anyone help me with this error above when I debug my web app project in vstudio.net?? I can't figure it out! It was working fine for months, and now all of a sudden it's not!!...
2
by: dc15 | last post by:
I am trying to write an application, taking input from various text boxes and appending it to a text file.... it was working, then I had to create various sub procedures to reflect limits set in...
0
by: mchuc7719 | last post by:
Hello, I have a Vb.Net 2005 ClassLibrary, when I try to compile using MSBee, only get errors. Before I to run the command line, I open in notepad the .vbproj and I was add the next line: ...
4
by: Dennis | last post by:
I have a page in ASP.NET 2.0. I add a button in design view and the page runs fine. I then double-click the button to create the click method in the code. Then when I run the page I get the...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.