Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Withevents "BC30506: Handles clause requires a WithEvents variable"

Status
Not open for further replies.

TanTrazz

Programmer
Aug 18, 2001
54
NL
Hi all,


Ive got a problem... I made a ASP.NET webpage. When i run it i've got this message:
---------------------------------------------------
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: BC30506: Handles clause requires a WithEvents variable defined in the containing type or one of its base types.

Source Error:



Line 2: Partial Class _Default
Line 3: Inherits System.Web.UI.Page
[red]Line 4: Private Sub FactuurControle_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles FactuurControle.RowDataBound[/red]
Line 5: If e.Row.RowType = DataControlRowType.DataRow Then
Line 6: 'determine the value of the UnitsInStock field

-----------------------------------------------------
Here is the code

Code:
Private Sub FactuurControle_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles FactuurControle.RowDataBound
        If e.Row.RowType = DataControlRowType.DataRow Then
            'determine the value of the UnitsInStock field
            Dim unitsInStock As Integer = _
            Convert.ToInt32(DataBinder.Eval(e.Row.DataItem, _
            "diff"))
            If unitsInStock < 0 Then
                ' color the background of the row yellow

                e.Row.Cells(7).ForeColor = Drawing.Color.Red
                e.Row.Cells(7).Font.Bold = True

            Else
                e.Row.Cells(7).ForeColor = Drawing.Color.Green
                e.Row.Cells(7).Font.Bold = True

            End If
        End If
    End Sub

I don't get it.

Plz Help

TnQ TanTrazz
 
It looks as though you may have created a new control at design time and the designer hasn't added the WithEvents declaration for the control. Try deleting the control and adding it again.


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
Hi ca8msm,

Ive deleted the grid. Created again, but still get the error.

TanTrazz
 
Hmmm it looks as though that it's still having the same problem then (it could be due to the name of the control - if you've added the control and named it the same, it may have got a bit mixed up). Try adding a completely new GridView to the page and adding a RowDataBound event to it (even try it in a new page if you want). If that fires correctly, you know it is a problem with that particular control.


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top