|
-
May 14th, 2008, 04:06 PM
#1
Thread Starter
Frenzied Member
[RESOLVED] [2005] Help with <asp:buttoncolumn>
Ok, here is my code.
asp Code:
<asp:DataGrid runat="server" ID = "testgrid" OnSelectedIndexChanged="testgrid_SelectedIndexChanged" OnItemCommand="Button_Click" Height="40px">
<HeaderStyle BackColor="Blue" ForeColor = "White"/>
<Columns >
<asp:ButtonColumn Text = "View Information" ButtonType="PushButton" ></asp:ButtonColumn>
</Columns>
</asp:DataGrid>
And in the codebehind I have:
asp.net Code:
void Button_Click(System.Object Sender, System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
MessageBox("Button Pushed!");
}
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
-
May 14th, 2008, 04:44 PM
#2
Re: [2005] Help with <asp:buttoncolumn>
public void Button_Click.........
-
May 15th, 2008, 08:23 AM
#3
Thread Starter
Frenzied Member
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:
Invalid postback or callback argument. Event validation is enabled using <pages
enableEventValidation="true"/> in configuration or <%@ Page EnableEventValidation="true" %> in a page.
For security purposes, this feature verifies that arguments to postback or callback events originate from
the server control that originally rendered them. If the data is valid and expected, use the
ClientScriptManager.RegisterForEventValidation method in order to register the postback or callback data
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
-
May 15th, 2008, 09:18 AM
#4
Thread Starter
Frenzied Member
Re: [2005] Help with <asp:buttoncolumn>
I figured out what it was, I wasn't putting:
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
-
May 16th, 2008, 01:31 PM
#5
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|