This is the 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.
And this is what I'm doing:
aspx:
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
myUserControl.DataBind();
}
}
usercontrol:
public override void DataBind()
{
ddlContacts.DataSource = SessionHandler.Contacts;
ddlContacts.DataValueField = "Id";
ddlContacts.DataTextField = "Name";
ddlContacts.DataBind();
ddlOrderbillto.DataSource = SessionHandler.Contacts;
ddlOrderbillto.DataValueField = "Id";
ddlOrderbillto.DataTextField = "Name";
ddlOrderbillto.DataBind();
ddlState.DataSource = SessionHandler.FederalStates;
ddlState.DataTextField = "Name";
ddlState.DataValueField = "Id";
ddlState.DataBind();
if (Info.Id > 0)
{
//load info
}
}
As you can see I have 2 dropdown lists that I load ddlContacts
and ddlOrderbillto
and everything worked like it was supposed to. As soon as I added ddlState
all the sudden I get the error I mentioned above. I've tried putting it inside an update panel and nothing. If I comment the ddlState
datasource, databinding then it works but obviously I'm left with no states :(
Help please?
EDIT: I have 2 other dropdown lists "ddlCounties" and "ddlCity" which when page databinds they are blank, but upon changing "ddlState" they get populated through jquery. So from what I've read is that because they are not loaded originally then this could be the error?