473,396 Members | 1,814 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Dropdownlist Error

Hello,

I've searched the groups unsuccessfully to the solution to this
problem. I've seen a few others making note of it, but it didn't seem
like there were any solutions.

I have a drop down list in vb.net, and when I do a DataBind on it, I
get an error "The 'SelectedIndex' and 'SelectedValue' attributes are
mutually exclusive." Basically, this doesn't happen all the time-It
happens after certain specific events take place. This seems to happen
only when data is re-binded to the page.

The code where this happens is as follows:
ddlVersionList.DataSource =
dsProductVersionList.Tables("ProductVersionList")
ddlVersionList.DataTextField = "Version"
ddlVersionList.DataValueField =
"PDP__Product_Version_ID"
ddlVersionList.DataBind()

I'm totally lost, since I'm not doing anything with the SelectedIndex
and SelectedValue until after the DataBind. I'm also clearing the drop
down list prior to executing this code.

Any suggestions would be greatly appreciated.

Thanks!

-Dave-

Oct 19 '06 #1
1 1328
I've been fighting the exact same problem, using .DataBind() to populate the
Items collection of a DropDownList control that already has data in it, even
though i call .ClearSelection() and .Items.Clear() before calling
..DataBind().

In my case I wasn't binding it to a DataTable, but instead it was in a
generic procedure that accepts an ICollection object and the two property
names and binds the control to that.

I couldn't find a solution (I think its just a bug in the DataBind method),
but to work around it i created another generic procedure that takes the
ICollection object and property names and using reflection builds a
ListItem() array that can then be used to populate the DropDownList using the
Items.AddRange() method. This works just fine with no errors. You could
probably create a similar procedure to access the rows and columns of the
table, and return a ListItem() collection.

Rae
"re******@yahoo.com" wrote:
Hello,

I've searched the groups unsuccessfully to the solution to this
problem. I've seen a few others making note of it, but it didn't seem
like there were any solutions.

I have a drop down list in vb.net, and when I do a DataBind on it, I
get an error "The 'SelectedIndex' and 'SelectedValue' attributes are
mutually exclusive." Basically, this doesn't happen all the time-It
happens after certain specific events take place. This seems to happen
only when data is re-binded to the page.

The code where this happens is as follows:
ddlVersionList.DataSource =
dsProductVersionList.Tables("ProductVersionList")
ddlVersionList.DataTextField = "Version"
ddlVersionList.DataValueField =
"PDP__Product_Version_ID"
ddlVersionList.DataBind()

I'm totally lost, since I'm not doing anything with the SelectedIndex
and SelectedValue until after the DataBind. I'm also clearing the drop
down list prior to executing this code.

Any suggestions would be greatly appreciated.

Thanks!

-Dave-

Nov 1 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: Stanley J Mroczek | last post by:
How do you load a dropdownlist when edit is clicked in a datagrid ? <Columns> <asp:BoundColumn DataField="OptionDescription" ItemStyle-Wrap="True" HeaderText="Option...
1
by: DC Gringo | last post by:
I'm having such a problem with this DropDownList in a user control that is posting back and throwing an error: System.Web.HttpException: A DropDownList cannot have multiple items selected ...
2
by: Antonio D'Ottavio | last post by:
Good Morning, In my web page I've a datalist that is sourced by a database, the problem is that I want that one of the column of the datalist contain a dropdownbox that also is sourced by a table...
2
by: rmorvay | last post by:
I am trying to dynamically build a dropdownlist and bind it to a cell in a grid. I tried to utilize the following code but I am stuck at the point where I bind the dropdownlist to the grid cell. ...
4
by: theo | last post by:
Program flow...load file,then extract the xml text tags from the file,then the number of Xml tags retrieved from the file determines the number of dropdownlist controls instanciated in the...
0
by: dhnriverside | last post by:
Hi peeps OK, I'm getting a weird error trying to select a DDL item based on what's stored in the database. I have 4 DDLs on my aspx page... <asp:dropdownlist id="ddlStartTimeHour"...
10
by: dhnriverside | last post by:
Hi guys Still having a problem with this dropdownlist. Basically, I've got 4. The first 2 work fine, then my code crashes on the 3rd. ddlEndTimeHour.Items.FindByValue(endTime).Selected =...
10
by: ads | last post by:
hi, after binding the dropdownlist to a datasource, ive experience this error "Cannot have multiple items selected in a dropdownlist" after using the code:...
2
by: =?Utf-8?B?VmljdG9yaW91czE=?= | last post by:
When the editcommand is execured for my datagrid the dropdown list appears for the bound item status. However, the item selected by default does not match the unedited data. How do I make the...
0
by: asmx126453 | last post by:
Hey mensen I am having some big troubles here i tryd solving it myself with internet for 2 days but i kind fix it. Its about this i have a DotNet project that alrydi is online and working for...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.