468,536 Members | 1,498 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,536 developers. It's quick & easy.

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

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

Mar 7 '07 #1
4 7788
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.

"Dooman" wrote:
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

Mar 21 '07 #2
What kind of error are you receiving?
It would be helpful to know exactly what the error says - and then, possibly
your code for population.

--
David Wier
MVP/ASPInsider
http://aspnet101.com
http://aspexpress.com

"Bobby Cochran" <Bo**********@discussions.microsoft.comwrote in message
news:84**********************************@microsof t.com...
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.

"Dooman" wrote:
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

Mar 21 '07 #3
"Dooman" <ra***********@gmail.comwrote in message
news:11*********************@j27g2000cwj.googlegro ups.com...
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...
Mar 21 '07 #4
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 <alink 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

"David Wier" wrote:
What kind of error are you receiving?
It would be helpful to know exactly what the error says - and then, possibly
your code for population.

--
David Wier
MVP/ASPInsider
http://aspnet101.com
http://aspexpress.com

"Bobby Cochran" <Bo**********@discussions.microsoft.comwrote in message
news:84**********************************@microsof t.com...
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.

"Dooman" wrote:
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
>
>


Mar 21 '07 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

8 posts views Thread by arun | last post: by
2 posts views Thread by arun | last post: by
reply views Thread by NPC403 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.