The error message tells you exactly what is happening: the value, for example, stored in mr.rankid, is not in the drop-down list.
You need to find out if the drop-down list contains the correct value or the value you are trying to assign does not exist in the list of available values.
Update
Since the visibility of the panel, which appears to be causing problems, it would be better to hide the panel using CSS than setting the Visible property to false, which would prevent it from being displayed on the page.
This can be done with code similar to the following in code:
Panel1.Style.Add(HtmlTextWriterStyle.Visibility, "Hidden"); Panel1.Style.Add(HtmlTextWriterStyle.Display, "None");
source share