If you know up front the data that could be populated, you can use the ClientScriptManager to resolve this issue. I had this issue when dynamically populating a drop down box using javascript on a previous user selection.
Here is some example code for overriding the render method (in VB and C#) and declaring a potential value for the dropdownlist ddCar.
In VB:
Protected Overrides Sub Render(ByVal writer As System.Web.UI.HtmlTextWriter)
Dim ClientScript As ClientScriptManager = Page.ClientScript
ClientScript.RegisterForEventValidation("ddCar", "Mercedes")
MyBase.Render(writer)
End Sub
or a slight variation in C# could be:
protected override void Render(HtmlTextWriter writer)
{
Page.ClientScript.RegisterForEventValidation("ddCar", "Mercedes");
base.Render(writer);
}
For newbies: This should go in the code behind file (.vb or .cs) or if used in the aspx file you can wrap in <script>
tags.