问题描述
pretty简单的问题。我很肯定我有类,方法,codebehind等正确关联。很多帖子在网上说这事做编译和/或DLL / bin中的文件,但没有他们的帮助很适合我。
Pretty simple question. I'm quite certain I have the Class, method, codebehind, etc linked properly. Lot's of posts online say that this has something to do with compiling and/or dll/bin files, but none of their help has worked for me.
Compiler Error Message: BC30456: 'gvLegs_PageIndexChanging' is not a member of 'ASP.nestedgridview_aspx'.
Source Error:
Line 43: <asp:Label ID="lblEmpName" runat="server" Text='<%# Eval("Location")%>'></asp:Label>
Line 44: <asp:Literal runat="server" ID="lit1" Text="</td><tr id='trCollapseGrid' style='display:none' ><td colspan='5'>" />
Line 45: <asp:GridView ID="gvLegs" AutoGenerateColumns="False" runat="server" EnableViewState="False"
Line 46: DataKeyNames="EmployeeId" ForeColor="#333333" PageSize="4" AllowPaging="True"
Line 47: OnPageIndexChanging="gvLegs_PageIndexChanging">
Source File: C:\Users\tstanley\Desktop\NestedVB\NestedVB\NestedGridView.aspx Line: 45
NestedGridView.aspx
NestedGridView.aspx
<%@ Page Language="vb" AutoEventWireup="false" codebehind="NestedGridView.aspx.vb" Inherits="NestedVB.NestedGridViewPaging2" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
NetedGridView.aspx.vb [code后面]
...
NetedGridView.aspx.vb [Code Behind]...
Private Sub gvLegs_PageIndexChanging(sender As Object, e As GridViewPageEventArgs)
如果任何人有这个修复,这会对我们帮助很大,所以我可以继续调试....实际code笑。
If anyone has a fix for this, it would help me greatly so I can continue.... debugging the actual code lol.
推荐答案
gvLegs_PageIndexChanging
是私有的,但需要保护或公开。
gvLegs_PageIndexChanging
is private but needs to be protected or public.
由于您使用VB.NET,你也可以使用:
Since you're using VB.NET you could also use the handles clause:
Private Sub gvLegs_PageIndexChanging(sender As Object, e As GridViewPageEventArgs) _
Handles gvLegs.PageIndexChanging
End Sub
修改:只要是明确的,你必须在ASP.NET三种选择用VB.NET创建事件处理程序:
Edit: Just to be clear, you have three options in ASP.NET with VB.NET to create event handlers:
- 声明上ASPX
- 在code。与
- 使用(大多为在VB动态控制.NET)
- declaratively on aspx
- in code with handles clause
- with AddHandler (mostly for dynamical controls in VB.NET)
如果您使用选项1事件处理程序至少必须得到保护,因为aspx页面从codebehind类继承。
If you use option 1 the event handler must at least be protected since the aspx page inherits from the codebehind class.
如果您使用选项2的方法可以是私有的,但你需要删除的ASPX声明事件处理程序。
If you use option 2 the method can be private but you need to remove the declarative event handler on the aspx.
这篇关于错误BC30456:'[方法]'不是一个成员。“ASP [codeBehind] _aspx”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!