是不是跟codebehind有关啊?我是框架和代码分离的

解决方案 »

  1.   

    你如果在codebehind中指明了,应该不会出这问题!
    贴一段你的codebehind程序出来!要头部!
      

  2.   

    在代码中,把MyDataGrid_EditCommand声明成public
      

  3.   

    newslist.aspx.vb
    ------------------------------------
    Imports System.Data.SqlClient
    Imports System.DataPublic Class newslist
        Inherits System.Web.UI.Page
        Protected WithEvents Button1 As System.Web.UI.WebControls.Button
        Protected WithEvents Label1 As System.Web.UI.WebControls.Label
        Protected WithEvents Panel1 As System.Web.UI.WebControls.Panel
        Protected WithEvents EventData As System.Web.UI.WebControls.DataGrid
        Protected WithEvents MyDataGrid As System.Web.UI.WebControls.DataGrid#Region " Web Form Designer Generated Code "    'This call is required by the Web Form Designer.
        <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()    End Sub    Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
            'CODEGEN: This method call is required by the Web Form Designer
            'Do not modify it using the code editor.
            InitializeComponent()
        End Sub#End Region    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            'Put user code to initialize the page here
            Dim DS As DataSet
            Dim MyConnection As SqlConnection
            Dim MyCommand As SqlDataAdapter
            '同数据库进行连接,采用sql server数据库
            MyConnection = New SqlConnection(ConfigurationSettings.AppSettings("ConnectionString"))
            '执行SQL操作
            MyCommand = New SqlDataAdapter("select *  from tbl_news order by id desc", MyConnection)        DS = New DataSet()
            MyCommand.Fill(DS, "tbl_news")
            MyDataGrid.DataSource = DS.Tables("tbl_news").DefaultView
            MyDataGrid.DataBind()
        End Sub    'Sub bindgrid()
        '    MyDataGrid.DataSource = createdataview()
        'End Sub    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            Response.Redirect("addnews.aspx")
        End Sub    Sub change_page_index(ByVal sender As Object, ByVal e As DataGridPageChangedEventArgs)
            MyDataGrid.CurrentPageIndex = e.NewPageIndex
            MyDataGrid.DataBind()
        End Sub    Public Sub MyDataGrid_EditCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles MyDataGrid.EditCommand
            MyDataGrid.EditItemIndex = e.Item.ItemIndex
            'bindgrid()
        End Sub    Private Sub MyDataGrid_CancelCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles MyDataGrid.CancelCommand    End Sub
    End Class
      

  4.   

    没有必要再在HTML中指定OnEditCommand了嘛。