Hi.
I am having a big problem solving this error:
"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."
Scenario:
I have a gridView which loads data when the page loads for the first
time. In the same page i have one search user control outside of
GridView which have dropdown and a submit button. User select from
dropdown and click submit button to pass dropdown selected index. The
page reloads and bind the Grid again with new information related with
search.
My GridView also have one user control inside gridview ItemTemplate
which have dynamically created labels, textboxes, checkboxes. Such
that when each row of GridView is clicked, user control shows up with
data related with that particular gridview row.
Now, When i do search GridView filters out the information and show
data correctly, which is fine till here, but once i click on each row
to see the content of user control it display the above error.
When no search is performed, everything works fine.
Please help me to solve this problem. Is it because i am binding
gridview on Page_Load for second time when search is performed. If
yes, then is there any other alternative to bind gridview with other
data source.
Any help would be appreciated alot.
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
DataTable mDT = Utility.BuildDataTable("SELECT * FROM TABLE");
GridView1.DataSource = mDT;
GridView1.DataBind();
}
// Search results
int ddltypeID = ddl.SelectedValue;
String strSql = "";
String strAnd = "";
if (ddltypeID != -1)
{
strSql = strSql + strAnd + "Measure_Type = " + UCTypeID;
DataTable dt = msadapter.GetData();
DataRow[] dr = dt.Select(strSql);
GridView1.DataSource = dr;
GridView1.DataBind();
}
}