Murray Brown
asked on
ASP.net Error clicking a button in a GridView column
Hi. When running the following cofde through a button on a GridView I am getting the error
shown below
Private Sub GridView1_RowCommand1(send er As Object, e As System.Web.UI.WebControls. GridViewCo mmandEvent Args) Handles GridView1.RowCommand
Try
If (e.CommandName = "MyButton6") Then
' Retrieve the row index stored in the CommandArgument property.
Dim index As Integer = Convert.ToInt32(e.CommandA rgument)
' Retrieve the row that contains the button
' from the Rows collection.
Dim row As GridViewRow = GridView1.Rows(index)
row.BackColor = Drawing.Color.LightCyan
row.Cells(6).ForeColor = Drawing.Color.DarkGreen
End If
Catch ex As Exception
Me.lblError1.Text = ex.Message
End Try
End Sub
Server Error in '/' Application.
-------------------------- ---------- ---------- ---------- ---------- ---------- ----
Invalid postback or callback argument. Event validation is enabled using <pages enableEventValidation="tru e"/> in configuration or <%@ Page EnableEventValidation="tru e" %> 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.Regist erForEvent Validation method in order to register the postback or callback data for validation.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.ArgumentException: Invalid postback or callback argument. Event validation is enabled using <pages enableEventValidation="tru e"/> in configuration or <%@ Page EnableEventValidation="tru e" %> 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.Regist erForEvent Validation method in order to register the postback or callback data for validation.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[ArgumentException: Invalid postback or callback argument. Event validation is enabled using <pages enableEventValidation="tru e"/> in configuration or <%@ Page EnableEventValidation="tru e" %> 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.Regist erForEvent Validation method in order to register the postback or callback data for validation.]
System.Web.UI.ClientScript Manager.Va lidateEven t(String uniqueId, String argument) +8778454
System.Web.UI.Control.Vali dateEvent( String uniqueID, String eventArgument) +113
System.Web.UI.WebControls. Button.Rai sePostBack Event(Stri ng eventArgument) +35
System.Web.UI.WebControls. Button.Sys tem.Web.UI .IPostBack EventHandl er.RaisePo stBackEven t(String eventArgument) +10
System.Web.UI.Page.RaisePo stBackEven t(IPostBac kEventHand ler sourceControl, String eventArgument) +13
System.Web.UI.Page.RaisePo stBackEven t(NameValu eCollectio n postData) +36
shown below
Private Sub GridView1_RowCommand1(send
Try
If (e.CommandName = "MyButton6") Then
' Retrieve the row index stored in the CommandArgument property.
Dim index As Integer = Convert.ToInt32(e.CommandA
' Retrieve the row that contains the button
' from the Rows collection.
Dim row As GridViewRow = GridView1.Rows(index)
row.BackColor = Drawing.Color.LightCyan
row.Cells(6).ForeColor = Drawing.Color.DarkGreen
End If
Catch ex As Exception
Me.lblError1.Text = ex.Message
End Try
End Sub
Server Error in '/' Application.
--------------------------
Invalid postback or callback argument. Event validation is enabled using <pages enableEventValidation="tru
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.ArgumentException: Invalid postback or callback argument. Event validation is enabled using <pages enableEventValidation="tru
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[ArgumentException: Invalid postback or callback argument. Event validation is enabled using <pages enableEventValidation="tru
System.Web.UI.ClientScript
System.Web.UI.Control.Vali
System.Web.UI.WebControls.
System.Web.UI.WebControls.
System.Web.UI.Page.RaisePo
System.Web.UI.Page.RaisePo
ASKER
Thanks but I am looking for help with why my code be incorrect
Are you using an updatepanel?
Can u post the Gridview markup from the aspx page?
Can u post the Gridview markup from the aspx page?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Hello,
Is the GridView handling the RowCommand trigger?
Ryan F
Is the GridView handling the RowCommand trigger?
<asp:GridView ID="GridView1" runat="server"
onrowcommand="GridView1_RowCommand1">
Ryan F
ASKER
Thanks very much
http://blogs.msdn.com/b/amitsh/archive/2007/07/31/why-i-get-invalid-postback-or-callback-argument-errors.aspx