The 'SelectedIndex' and 'SelectedValue' attributes are mutually exclusive

D

Dooman

Hello,

I am getting this error when binding a drop down list box to a
dataset:

The 'SelectedIndex' and 'SelectedValue' attributes are mutually
exclusive

I have looked at other posts and they al refer to this error when
accessing data in the list box.

Any ideas?

Thanks!
Randy DeForest
 
G

Guest

I am having this same problem when filling a drop down list. Did you ever
find a solution to this? Any help would be appreciated.
 
M

Mark Rae

I am getting this error when binding a drop down list box to a
dataset:

The 'SelectedIndex' and 'SelectedValue' attributes are mutually
exclusive

I have looked at other posts and they al refer to this error when
accessing data in the list box.

Yes indeed - I've seen this error before when tying to select a ListItem
programmatically, but never during databinding...

As has already been mentioned, please post your code...
 
G

Guest

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top