Prob w/ Datagrid

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • brock wade

    #1

    Prob w/ Datagrid

    I have a Datagrid with the following code:

    <Columns>
    <asp:TemplateCo lumn>
    <ItemTemplate >
    <asp:LinkButt on ID="LinkButton1 " CommandArgument ='<%# Eval("id") %>'
    runat="server" OnClick="LinkBu tton1_Click">De tails</
    asp:LinkButton> Details</asp:LinkButton>
    </ItemTemplate>
    </asp:TemplateCol umn>
    </Columns>

    I'm getting this error message:
    Compiler Error Message: BC30456: 'LinkButton1_Cl ick' is not a member
    of 'ASP.MainDepart ment_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!!!
  • Norm

    #2
    Re: Prob w/ Datagrid

    On Jun 30, 9:11 am, brock wade <brockusw...@ya hoo.comwrote:
    I have a Datagrid with the following code:
    >
    <Columns>
    <asp:TemplateCo lumn>
    <ItemTemplate >
    <asp:LinkButt on ID="LinkButton1 " CommandArgument ='<%# Eval("id") %>'
    runat="server" OnClick="LinkBu tton1_Click">De tails</
    asp:LinkButton> Details</asp:LinkButton>
    </ItemTemplate>
    </asp:TemplateCol umn>
    </Columns>
    >
    I'm getting this error message:
    Compiler Error Message: BC30456: 'LinkButton1_Cl ick' is not a member
    of 'ASP.MainDepart ment_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_Cl ick' member in the code-behind?

    Comment

    • brock wade

      #3
      Re: Prob w/ Datagrid

      Another item that may shed some light:

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

      Private Sub LinkButton1_Cli ck(ByVal source As Object, ByVal e As
      System.Web.UI.W ebControls.Data GridCommandEven tArgs)
      Response.Redire ct("Details.asp x?id=" & ID.ToString())
      End Sub

      On Jun 30, 12:11 pm, brock wade <brockusw...@ya hoo.comwrote:
      I have a Datagrid with the following code:
      >
      <Columns>
      <asp:TemplateCo lumn>
      <ItemTemplate >
      <asp:LinkButt on ID="LinkButton1 " CommandArgument ='<%# Eval("id") %>'
      runat="server" OnClick="LinkBu tton1_Click">De tails</
      asp:LinkButton> Details</asp:LinkButton>
      </ItemTemplate>
      </asp:TemplateCol umn>
      </Columns>
      >
      I'm getting this error message:
      Compiler Error Message: BC30456: 'LinkButton1_Cl ick' is not a member
      of 'ASP.MainDepart ment_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!!!

      Comment

      • Norm

        #4
        Re: Prob w/ Datagrid

        On Jun 30, 10:30 am, brock wade <brockusw...@ya hoo.comwrote:
        Another item that may shed some light:
        >
        I have this to handle the button in my code-behind:
        >
            Private Sub LinkButton1_Cli ck(ByVal source As Object, ByVal e As
        System.Web.UI.W ebControls.Data GridCommandEven tArgs)
                Response.Redire ct("Details.asp x?id=" & ID.ToString())
            End Sub
        >
        On Jun 30, 12:11 pm, brock wade <brockusw...@ya hoo.comwrote:
        >
        I have a Datagrid with the following code:
        >
        <Columns>
        <asp:TemplateCo lumn>
        <ItemTemplate >
        <asp:LinkButt on ID="LinkButton1 " CommandArgument ='<%# Eval("id") %>'
        runat="server" OnClick="LinkBu tton1_Click">De tails</
        asp:LinkButton> Details</asp:LinkButton>
        </ItemTemplate>
        </asp:TemplateCol umn>
        </Columns>
        >
        I'm getting this error message:
        Compiler Error Message: BC30456: 'LinkButton1_Cl ick' is not a member
        of 'ASP.MainDepart ment_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_Cli ck(ByVal source As Object, ByVal e As
        System.Web.UI.W ebControls.Comm andEventArgs)
        Response.Redire ct("Details.asp x?id=" &
        e.CommandArgume nt.ToString())
        End Sub

        <Columns>
        <asp:TemplateCo lumn>
        <ItemTemplate >
        <asp:LinkButt on ID="LinkButton1 " CommandArgument ='<%# Eval("id") %>'
        runat="server" OnCommand="Link Button1_Click"> Details</
        asp:LinkButton> Details</asp:LinkButton>
        </ItemTemplate>
        </asp:TemplateCol umn>
        </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!

        Comment

        • marss

          #5
          Re: Prob w/ Datagrid

          On Jun 30, 8:30 pm, brock wade <brockusw...@ya hoo.comwrote:
          Another item that may shed some light:
          >
          I have this to handle the button in my code-behind:
          >
          Private Sub LinkButton1_Cli ck(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

          Comment

          • wade.brock@yahoo.com

            #6
            Re: Prob w/ Datagrid

            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 -

            Comment

            • Norm

              #7
              Re: Prob w/ Datagrid

              On Jul 1, 12:42 pm, wade.br...@yaho o.com 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.

              Comment

              Working...