Server Error in '/Home' Application.
--------------------------------------------------------------------------------Compilation Error 
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.Source Error: Line 59:         End Sub
Line 60:         '翻页事件过程
Line 61:         Private Sub DataGrid1_PageIndexChanged(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridPageChangedEventArgs) Handles DataGrid1.PageIndexChanged
Line 62:             DataGrid1.CurrentPageIndex = e.NewPageIndex
Line 63:             getdata()
 Source File: D:\inetpub\wwwroot\home\default3.aspx    Line: 61 

解决方案 »

  1.   

    这是代码<%@ Page Language="vb" AutoEventWireup="false"%>
    <%@ Import Namespace="System.Data"%>
    <%@ Import Namespace ="System.Data.OleDb"%>
    <%@ Import Namespace="System.IO"%>
    <%@ Import Namespace="System.Web.UI" %>
    <%@ Import Namespace="System.Web.UI.WebControls" %><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <html>
    <head runat="server">
        <title>Pending Tray</title>
        <script runat="server" >
        
                
            'Inherits System.Web.UI.Page
            
            Public mycon As OleDb.OleDbConnection
            Public Shared ada As OleDbDataAdapter
            Sub myconn()
                mycon = New OleDbConnection            mycon.ConnectionString = "provider=microsoft.jet.oledb.4.0;data source=" + Server.MapPath(".") + "\Training\ImportActivity\PendingTray\App_Data\importPending.mdb"            ada = New OleDbDataAdapter
                ada.SelectCommand = New OleDbCommand
                ada.InsertCommand = New OleDbCommand
                ada.UpdateCommand = New OleDbCommand
                ada.DeleteCommand = New OleDbCommand            ada.SelectCommand.Connection = mycon
                ada.InsertCommand.Connection = mycon
                ada.UpdateCommand.Connection = mycon
                ada.DeleteCommand.Connection = mycon
            End Sub
            Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
                If Not IsPostBack Then
                    getdata()
                    '调用数据绑定过程
                End If
            End Sub
            '下面是数据绑定过程
            Sub getdata()
                Try
                    myconn()
                    Dim dt As Data.DataSet = New Data.DataSet
                    Dim sql As String
                    sql = "select * from pending"
                    myconn()
                    ada.SelectCommand.CommandText = sql
                    mycon.Open()
                    ada.Fill(dt)
                    DataGrid1.DataSource = dt.Tables(0).DefaultView
                    DataGrid1.DataBind()
                Catch ex As Exception
                    Response.Write("程序出现错误,信息描述如下:<br>" & ex.Message.ToString)
                Finally
                    mycon.Close()
                End Try
            End Sub
            '翻页事件过程
            Private Sub DataGrid1_PageIndexChanged(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridPageChangedEventArgs) Handles DataGrid1.PageIndexChanged
                DataGrid1.CurrentPageIndex = e.NewPageIndex
                getdata()
            End Sub
            '请求排列顺序事件过程
            Private Sub DataGrid1_SortCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridSortCommandEventArgs)
                ViewState("sort") = e.SortExpression.ToString
                getdata()
            End Sub
            '切换到更新状态  
            Private Sub DataGrid1_EditCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs)
                DataGrid1.EditItemIndex = e.Item.ItemIndex
                getdata()
                '刷新数据
            End Sub
            '取消编辑状态
            Private Sub DataGrid1_CancelCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs)
                DataGrid1.EditItemIndex = -1
                '切换到正常状态
                getdata()
                '刷新数据
            End Sub
            'DataGrid1_UpdateCommand事件过程是.NET框架运行时托管的,当按下更新按钮时,就执行更新数据过程
            Private Sub DataGrid1_UpdateCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs)
                Dim id As String = e.Item.Cells(0).Text.ToString
                '这里是获取当前更改的记录ID值,
                'e.Item.Cells(0).Text返回的是DataGrid表格中第一列的值()
                Dim week As String = CType(e.Item.Cells(1).Controls(0), TextBox).Text
                '这里是获取当前更改的后的值, CType(e.Item.Cells(1).Controls(0), 
                'TextBox).Text是先将e.Item.Cells(1).Controls(0)转转成TextBox控件类型,
                '然后获取它的Text值()
                Dim sql As String
                sql = "update  student set week='" + week + "'  where  id=" + id
                myconn()
                ada.UpdateCommand.CommandText = sql
                mycon.Open()
                ada.UpdateCommand.ExecuteNonQuery()
                mycon.Close()
                Response.Write("<script>alert('恭喜您!您已经成功更新了了" & week & "的记录!');</" & "script>")
                DataGrid1.EditItemIndex = -1
                '改变编辑按钮状态
                getdata()
                '刷新数据
            End Sub
            ' 删除记录事件过程
            Private Sub DataGrid1_DeleteCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs)
                'Dim mycon As OleDb.OleDbConnection = New OleDb.OleDbConnection("provider=microsoft.jet.oledb.4.0;data source=" + Server.MapPath(".") + "\App_Data\importPending.mdb")
                Dim mysql As String
                mysql = "delete from pending where id=" & e.Item.Cells(0).Text
                myconn()
                ada.DeleteCommand.CommandText = mysql
                mycon.Open()
                ada.DeleteCommand.ExecuteNonQuery()
                mycon.Close()
                Response.Write("<script>alert('恭喜您!您已经成功删除了" & e.Item.Cells(1).Text & "的记录!');</" & "script>")
                getdata()
            End Sub
            
        
        
        </script>
      

  2.   

    也挺奇怪,我把上面的代码放在以个.VB文件中引用,但也不行,错误提示如下。Server Error in '/Home' Application.
    --------------------------------------------------------------------------------Parser Error 
    Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately. Parser Error Message: Could not load type 'Default3'.Source Error: 
    Line 1:  <%@ Page Language="vb" AutoEventWireup="false" Codefile="Default3.aspx.vb" Inherits="Default3"%>
    Line 2:  
    Line 3:  
     Source File: D:\inetpub\wwwroot\home\training\importactivity\pendingtray\default3.aspx    Line: 1 
    --------------------------------------------------------------------------------
    Version Information: Microsoft .NET Framework Version:1.1.4322.2407; ASP.NET Version:1.1.4322.2407 
      

  3.   

    2.0的程序好像不能在1.1 framework运行
      

  4.   

    你的DataGrid1_PageIndexChanged事件在哪调用的?应该在html代码中DataGrid1的属性里有调用,仔细检查以下,错误原因是没有事件的注册
      

  5.   

    你的DataGrid1_PageIndexChanged事件在哪调用的?应该在html代码中DataGrid1的属性里有调用,仔细检查以下,错误原因是没有事件的注册
      

  6.   

    使用了未定义的行为!ps:你最好给你的机子装上net的中文语言包,看不明白e文,就看中文把