一个奇怪的问题。请各路大侠关注!谢谢!

iStringTheory 2002-05-10 09:35:27
遇到一个很奇怪的问题:
系统报错为:
Compiler Error Message: BC30456: 'MyDataGrid_EditCommand' is not a member of 'ASP.newslist_aspx'.

出错代码为:
Line 14: <asp:datagrid id="MyDataGrid" style="Z-INDEX: 104; LEFT: 14px; POSITION: absolute; TOP: 45px" runat="server" Width="500px" AllowPaging="True" Font-Size="9pt" Font-Names="SimSun" CellPadding="5" BorderColor="Black" BorderWidth="1px" OnPageIndexChanged="change_page_index" AutoGenerateColumns="False" OnEditCommand="MyDataGrid_EditCommand">

说明:MyDataGrid_EditCommand是codebehind内的一个处理程序
...全文
28 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
iStringTheory 2002-05-10
  • 打赏
  • 举报
回复
谢了!各位!
icyer 2002-05-10
  • 打赏
  • 举报
回复
没有必要再在HTML中指定OnEditCommand了嘛。
iStringTheory 2002-05-10
  • 打赏
  • 举报
回复
newslist.aspx.vb
------------------------------------
Imports System.Data.SqlClient
Imports System.Data

Public 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
icyer 2002-05-10
  • 打赏
  • 举报
回复
在代码中,把MyDataGrid_EditCommand声明成public
happynet 2002-05-10
  • 打赏
  • 举报
回复
你如果在codebehind中指明了,应该不会出这问题!
贴一段你的codebehind程序出来!要头部!
iStringTheory 2002-05-10
  • 打赏
  • 举报
回复
是不是跟codebehind有关啊?我是框架和代码分离的

62,046

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧