Results 1 to 5 of 5

Thread: [RESOLVED] [2005] Help with <asp:buttoncolumn>

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Feb 2008
    Location
    Texas
    Posts
    1,288

    Resolved [RESOLVED] [2005] Help with <asp:buttoncolumn>

    Ok, here is my code.

    asp Code:
    1. <asp:DataGrid runat="server" ID = "testgrid" OnSelectedIndexChanged="testgrid_SelectedIndexChanged" OnItemCommand="Button_Click" Height="40px">
    2.     <HeaderStyle BackColor="Blue" ForeColor = "White"/>
    3.     <Columns >
    4.     <asp:ButtonColumn Text = "View Information" ButtonType="PushButton" ></asp:ButtonColumn>
    5.     </Columns>
    6.    
    7.     </asp:DataGrid>

    And in the codebehind I have:

    asp.net Code:
    1. void Button_Click(System.Object Sender, System.Web.UI.WebControls.DataGridCommandEventArgs e)
    2.     {
    3.         MessageBox("Button Pushed!");
    4.     }

    Now, when I compile, I'm getting this error:

    Error 3 'newpage.Button_Click(object, System.Web.UI.WebControls.DataGridCommandEventArgs)' is inaccessible due to its protection level C:\Documents and Settings\justin\My Documents\Visual Studio 2005\WebSites\AceSite\newpage.aspx 62


    I'm kinda stuck...

    Thanks for the help,

    Justin Fox
    You down with OOP? Yeah you know me!
    MCAD and MCMICKEYMOUSE (vb.net)

    ----

    If it even kinda helps... rate it : )

    Edit a Multi-page .tif file and save.

  2. #2
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: [2005] Help with <asp:buttoncolumn>

    public void Button_Click.........

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Feb 2008
    Location
    Texas
    Posts
    1,288

    Re: [2005] Help with <asp:buttoncolumn>

    Ok, I changed the method to public, and when I click the button, I get this error.

    vb Code:
    1. Invalid postback or callback argument.  Event validation is enabled using <pages
    2.  
    3.  enableEventValidation="true"/> in configuration or <%@ Page EnableEventValidation="true" %> in a page.
    4.  
    5.   For security purposes, this feature verifies that arguments to postback or callback events originate from
    6.  the server control that originally rendered them.  If the data is valid and expected, use the
    7.  ClientScriptManager.RegisterForEventValidation method in order to register the postback or callback data
    8.  
    9. for validation.

    I gave it a method to call, I don't get it.
    I put that eventenables stuff in my web.config file too.

    Thanks,

    Justin Fox
    You down with OOP? Yeah you know me!
    MCAD and MCMICKEYMOUSE (vb.net)

    ----

    If it even kinda helps... rate it : )

    Edit a Multi-page .tif file and save.

  4. #4

    Thread Starter
    Frenzied Member
    Join Date
    Feb 2008
    Location
    Texas
    Posts
    1,288

    Re: [2005] Help with <asp:buttoncolumn>

    I figured out what it was, I wasn't putting:

    asp Code:
    1. if(!IsPostBack)
    2. {
    3.  
    4. }

    Around my binding of my datagrid in my page_load function.
    so it was trying to bind the data everytime I pushed the button, and
    I guess it was doing away with my OnItemCommand stuff.

    Justin
    You down with OOP? Yeah you know me!
    MCAD and MCMICKEYMOUSE (vb.net)

    ----

    If it even kinda helps... rate it : )

    Edit a Multi-page .tif file and save.

  5. #5
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: [2005] Help with <asp:buttoncolumn>

    Yes, good work.

    The Page.IsPostBack is where people often get stuck the first time. When you rebind the control on every load, the viewstate information for it is lost. The viewstate information is what the application usually needs to know that an event has been raised or that some value has changed somewhere. By doing the postback check, the viewstate is preserved.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width