The error is odd, and only happens in one situation with me. I'll post code
below after I explain. The only time the error happens is when a control
with the same drop down information and ID on a previous page has a set
value. For instance, on my listing page I have a filter drop down with id
m_ddlActivityClass. When I select a filter value from that drop down and
postback, the list is altered. At that point, I choose an item from the
filtered list (gridview) to move to another page with detail of that item.
This page is called through a <a> link and never posts anything back, just
passes an ID with it for the next page. It is the next page that causes this
error:
The 'SelectedIndex' and 'SelectedValue' attributes are mutually exclusive.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information about
the error and where it originated in the code.
Exception Details: System.ArgumentException: The 'SelectedIndex' and
'SelectedValue' attributes are mutually exclusive.
Source Error:
Line 224: m_ddlActivityClass.DataValueField =
"ActivityClassTypeId";
Line 225: m_ddlActivityClass.DataTextField = "DisplayTitle";
Line 226: m_ddlActivityClass.DataBind();
Line 227: }
Line 228:
Again, this only happens when I have selected a value in the drop down on
the previous page. Otherwise, everything binds just fine. At the point from
which it crashes, I have not yet tried to set the selected value.
The code is as follows:
ActivityClassTypesFactory objFactory = new
ActivityClassTypesFactory(base.Connection);
ActivityClassTypesCollection objCollection = objFactory.ShowAll();
m_ddlActivityClass.DataSource = objCollection;
m_ddlActivityClass.DataValueField = "ActivityClassTypeId";
m_ddlActivityClass.DataTextField = "DisplayTitle";
m_ddlActivityClass.DataBind();
Thanks for the help!
Bobby