Prob w/ Datagrid

Discussion in 'ASP .Net' started by brock wade, Jun 30, 2008.

  1. brock wade

    brock wade Guest

    I have a Datagrid with the following code:

    <Columns>
    <asp:TemplateColumn>
    <ItemTemplate>
    <asp:LinkButton ID="LinkButton1" CommandArgument='<%# Eval("id") %>'
    runat="server" OnClick="LinkButton1_Click">Details</
    asp:LinkButton>Details</asp:LinkButton>
    </ItemTemplate>
    </asp:TemplateColumn>
    </Columns>

    I'm getting this error message:
    Compiler Error Message: BC30456: 'LinkButton1_Click' is not a member
    of 'ASP.MainDepartment_aspx'.

    Everything looks k in the design view.
    What are some places I should think of looking? BTW I'm using .NET 1.1

    Thanks!!!
    brock wade, Jun 30, 2008
    #1
    1. Advertising

  2. brock wade

    Norm Guest

    On Jun 30, 9:11 am, brock wade <> wrote:
    > I have a Datagrid with the following code:
    >
    > <Columns>
    > <asp:TemplateColumn>
    > <ItemTemplate>
    > <asp:LinkButton ID="LinkButton1" CommandArgument='<%# Eval("id") %>'
    > runat="server" OnClick="LinkButton1_Click">Details</
    > asp:LinkButton>Details</asp:LinkButton>
    > </ItemTemplate>
    > </asp:TemplateColumn>
    > </Columns>
    >
    > I'm getting this error message:
    > Compiler Error Message: BC30456: 'LinkButton1_Click' is not a member
    > of 'ASP.MainDepartment_aspx'.
    >
    > Everything looks k in the design view.
    > What are some places I should think of looking? BTW I'm using .NET 1.1
    >
    > Thanks!!!


    Is there a 'LinkButton1_Click' member in the code-behind?
    Norm, Jun 30, 2008
    #2
    1. Advertising

  3. brock wade

    brock wade Guest

    Another item that may shed some light:

    I have this to handle the button in my code-behind:

    Private Sub LinkButton1_Click(ByVal source As Object, ByVal e As
    System.Web.UI.WebControls.DataGridCommandEventArgs)
    Response.Redirect("Details.aspx?id=" & ID.ToString())
    End Sub

    On Jun 30, 12:11 pm, brock wade <> wrote:
    > I have a Datagrid with the following code:
    >
    > <Columns>
    > <asp:TemplateColumn>
    > <ItemTemplate>
    > <asp:LinkButton ID="LinkButton1" CommandArgument='<%# Eval("id") %>'
    > runat="server" OnClick="LinkButton1_Click">Details</
    > asp:LinkButton>Details</asp:LinkButton>
    > </ItemTemplate>
    > </asp:TemplateColumn>
    > </Columns>
    >
    > I'm getting this error message:
    > Compiler Error Message: BC30456: 'LinkButton1_Click' is not a member
    > of 'ASP.MainDepartment_aspx'.
    >
    > Everything looks k in the design view.
    > What are some places I should think of looking? BTW I'm using .NET 1.1
    >
    > Thanks!!!
    brock wade, Jun 30, 2008
    #3
  4. brock wade

    Norm Guest

    On Jun 30, 10:30 am, brock wade <> wrote:
    > Another item that may shed some light:
    >
    > I have this to handle the button in my code-behind:
    >
    >     Private Sub LinkButton1_Click(ByVal source As Object, ByVal e As
    > System.Web.UI.WebControls.DataGridCommandEventArgs)
    >         Response.Redirect("Details.aspx?id=" & ID.ToString())
    >     End Sub
    >
    > On Jun 30, 12:11 pm, brock wade <> wrote:
    >
    > > I have a Datagrid with the following code:

    >
    > > <Columns>
    > > <asp:TemplateColumn>
    > > <ItemTemplate>
    > > <asp:LinkButton ID="LinkButton1" CommandArgument='<%# Eval("id") %>'
    > > runat="server" OnClick="LinkButton1_Click">Details</
    > > asp:LinkButton>Details</asp:LinkButton>
    > > </ItemTemplate>
    > > </asp:TemplateColumn>
    > > </Columns>

    >
    > > I'm getting this error message:
    > > Compiler Error Message: BC30456: 'LinkButton1_Click' is not a member
    > > of 'ASP.MainDepartment_aspx'.

    >
    > > Everything looks k in the design view.
    > > What are some places I should think of looking? BTW I'm using .NET 1.1

    >
    > > Thanks!!!


    The LinkButton1 method has the wrong signature and you are not using
    the correct event. Below is the corrected code:

    Private Sub LinkButton1_Click(ByVal source As Object, ByVal e As
    System.Web.UI.WebControls.CommandEventArgs)
    Response.Redirect("Details.aspx?id=" &
    e.CommandArgument.ToString())
    End Sub

    <Columns>
    <asp:TemplateColumn>
    <ItemTemplate>
    <asp:LinkButton ID="LinkButton1" CommandArgument='<%# Eval("id") %>'
    runat="server" OnCommand="LinkButton1_Click">Details</
    asp:LinkButton>Details</asp:LinkButton>
    </ItemTemplate>
    </asp:TemplateColumn>
    </Columns>

    There are 3 changes.
    1: Instead of using OnClick, use OnCommand. Otherwise you dont get
    easy access to the command argument.
    2: Change the method signature to the one for the OnCommand event.
    3: Change the method to get the id from the command argument instead
    of ID. I have no idea where ID came from.

    Note: I left the method name alone, but now its confusing. I would
    change it to be something like ViewDetails. Something descriptive.
    Hope this helps!
    Norm, Jul 1, 2008
    #4
  5. brock wade

    marss Guest

    On Jun 30, 8:30 pm, brock wade <> wrote:
    > Another item that may shed some light:
    >
    > I have this to handle the button in my code-behind:
    >
    > Private Sub LinkButton1_Click(ByVal source As Object, ByVal e As


    Norm is right, the method has the wrong signature.
    Just one addition to his suggestion:
    You can't access private methods in the code-behind. They have to be
    protected at least.

    Mykola
    http://marss.co.ua
    marss, Jul 1, 2008
    #5
  6. brock wade

    Guest

    Thanks Norm,
    I rtied the changes and still get the Compiler Error Message: BC30456:
    'LinkButton1_Click' is not a member
    of 'ASP.MainDepartment_aspx'.

    Also I think I have my html in the wron order too... do you see any
    problems? It is re-underlining <form, <asp:datagrid, and <columns>

    <BODY>
    <div>
    <div>
    <form id="Form1" method="post" runat="server">
    <asp:datagrid id="dgEmployees" runat="server">
    <Columns>
    <asp:TemplateColumn>
    <ItemTemplate>
    <asp:LinkButton ID="LinkButton1" CommandArgument='<%#
    Eval("id") %&>'
    runat="server" OnCommand="LinkButton1_Click">Details</

    asp:LinkButton>Details</asp:LinkButton>
    </ItemTemplate>
    </asp:TemplateColumn>
    </Columns>
    </asp:datagrid>
    </form>
    <div>
    <asp:label id="Label4" runat="server" Width="253px">Type desired
    Excel Spreadsheet name without the .xls extension:</asp:label>
    <asp:textbox id="txtFileName" Runat="server"></asp:textbox>
    <asp:button id="Button1" onclick="doExport" runat="server"
    Width="123px" Text="Export to Excel"></asp:button>
    </div>
    </div>
    <asp:label id="EmpNum" " runat="server"></asp:label><asp:label
    id="Label1" runat="server">First Name</asp:label>
    <asp:label id="Label2" runat="server" >Last Name</asp:label></FORM></
    FORM>
    <DIV></DIV>
    <DIV></DIV>
    </div>
    </BODY>
    , Jul 1, 2008
    #6
  7. brock wade

    Guest

    Disregard my last post about my html being in the wrong order... I
    simply had an extra "Details</asp:LinkButton>" in the block....

    But I'm still getting this error message:

    Compiler Error Message: BC30456: 'LinkButton1_Click' is not a member
    of 'ASP.MainDepartment_aspx'.


    > <Columns>
    > <asp:TemplateColumn>
    > <ItemTemplate>
    > <asp:LinkButton ID="LinkButton1" CommandArgument='<%# Eval("id") %>'
    > runat="server" OnCommand="LinkButton1_Click">Details</
    > asp:LinkButton>Details</asp:LinkButton>
    > </ItemTemplate>
    > </asp:TemplateColumn>
    > </Columns>
    >
    , Jul 1, 2008
    #7
  8. brock wade

    Norm Guest

    On Jul 1, 9:59 am, wrote:
    > Disregard my last post about my html being in the wrong order... I
    > simply had an extra "Details</asp:LinkButton>" in the block....
    >
    > But I'm still getting this error message:
    >
    > Compiler Error Message: BC30456: 'LinkButton1_Click' is not a member
    > of 'ASP.MainDepartment_aspx'.
    >
    >
    >
    > > <Columns>
    > > <asp:TemplateColumn>
    > > <ItemTemplate>
    > > <asp:LinkButton ID="LinkButton1" CommandArgument='<%# Eval("id") %>'
    > > runat="server" OnCommand="LinkButton1_Click">Details</
    > > asp:LinkButton>Details</asp:LinkButton>
    > > </ItemTemplate>
    > > </asp:TemplateColumn>
    > > </Columns>- Hide quoted text -

    >
    > - Show quoted text -


    Thanks Marss I didn't notice that. Wade, read Marss post above. The
    reason that it is still throwing the error is becase it can't see it.
    Change "Private" to "Protected" or "Public".
    Norm, Jul 1, 2008
    #8
  9. brock wade

    Guest

    Yeah I thought that might have been it from other similar BC30456 "is
    not a member" posts, but changing to either Public or Protected did
    not work.

    >
    > Thanks Marss I didn't notice that. Wade, read Marss post above. The
    > reason that it is still throwing the error is becase it can't see it.
    > Change "Private" to "Protected" or "Public".- Hide quoted text -
    >
    > - Show quoted text -
    , Jul 1, 2008
    #9
  10. brock wade

    Norm Guest

    On Jul 1, 12:42 pm, wrote:
    > Yeah I thought that might have been it from other similar BC30456 "is
    > not a member" posts, but changing to either Public or Protected did
    > not work.
    >
    >
    >
    > > Thanks Marss I didn't notice that. Wade, read Marss post above. The
    > > reason that it is still throwing the error is becase it can't see it.
    > > Change "Private" to "Protected" or "Public".- Hide quoted text -

    >
    > > - Show quoted text -


    Well, I don't know what else to say other than post the full source of
    this page. There must be something else going wrong.
    Norm, Jul 1, 2008
    #10
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. drishtik

    dataset update prob

    drishtik, Sep 9, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    614
  2. paraag

    vhdl 2 blif prob

    paraag, Feb 18, 2004, in forum: VHDL
    Replies:
    0
    Views:
    1,181
    paraag
    Feb 18, 2004
  3. Replies:
    8
    Views:
    5,034
    Charles Bailey
    Feb 12, 2005
  4. Nisheeth

    multiplication prob

    Nisheeth, Mar 31, 2005, in forum: VHDL
    Replies:
    1
    Views:
    619
    Jonathan Bromley
    Mar 31, 2005
  5. slinky
    Replies:
    2
    Views:
    342
    slinky
    Oct 7, 2008
Loading...

Share This Page