error BC30456: '[Method]' is not a member of 'ASP.[CodeBehind]_aspx'

55,342

gvLegs_PageIndexChanging is private but needs to be protected or public.

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

Edit: Just to be clear, you have three options in ASP.NET with VB.NET to create event handlers:

  1. declaratively on aspx
  2. in code with handles clause
  3. with AddHandler (mostly for dynamical controls in VB.NET)

If you use option 1 the event handler must at least be protected since the aspx page inherits from the codebehind class.

If you use option 2 the method can be private but you need to remove the declarative event handler on the aspx.

Share:
55,342
Guy
Author by

Guy

Updated on July 09, 2022

Comments

  • Guy
    Guy almost 2 years

    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

    <%@ 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 Behind] ...

     Private Sub gvLegs_PageIndexChanging(sender As Object, e As GridViewPageEventArgs)
    

    If anyone has a fix for this, it would help me greatly so I can continue.... debugging the actual code lol.