See, you have entirely different issue and the way you asked/posted question was in different direction. You were trying to solve for something else.
Now, there could be few reasons why you are getting this issue. Easy/direct solution can be adding
enableEventValidation="false"
in your Page directive or Web.config file.
But, it is always good to hit the root cause. It might be that you are rebinding your grid on every postback. Thus, before RowCommand fire your GridView will rebind and all control within it will be assigned to new id. So
RowCommand
could not get the item which have fired the event. To avoid this, all you need to do is put your grid bind line in
IsPostBack
condition.
if (!IsPostBack)
{
}
Detailed explanation here:
Invalid postback or callback argument solution. Event validation...[
^]
Interesting to read one blog entry related to same:
“Invalid postback or callback argument” in ASP.NET[
^] - It exposes few other reasons on why one can get the same error. Nice read.