.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
david stephan
Gaurav Pal
Post New Web Links

'Dropdownlist' has a SelectedValue which is invalid because it does not exist in the list of items

Posted By:      Posted Date: October 04, 2010    Points: 0   Category :ASP.Net

I have a dropdown list that has a bind on it and I get this error. Why am I getting this error and what can I do to fix it. here is the code for the dropdown I currently have:


 <asp:DropDownList  ID="DDLPreferred" AppendDataBoundItems="true" SelectedValue='<%# Bind("PREFERRED_COMMUNICATION") %>'  runat="server" TabIndex="15">
                <asp:ListItem Text="none" Value=""></asp:ListItem>

				<asp:ListItem>Home Phone</asp:ListItem>
				<asp:ListItem>Work Phone</asp:ListItem>
				<asp:ListItem>Cell Phone</asp:ListItem>


View Complete Post

More Related Resource Links

Dropdownlist error: SelectedValue which is invalid because it does not exist in the list of items.


I have a dropdownlist in a detailsview edit Item template. Also I have two tables - Employee and Main. In the Employee table I have column EmpId and AssignedTo. In the main table I have EmpId which is connected to the Employee table. 

The detailsView has a label which shows the AssignedTo name for a particular record and it works fine. But if I click the edit button to shwo the dropdownlist in the editItemTemplate it is givig me the above error.

The code is:

<asp:DetailsView ID="dtvAssign" runat="server" AutoGenerateRows

'DropDownList6' has a SelectedValue which is invalid because it does not exist in the list of item


In my asp.net page I have a formview.  In the formview's InsertItemTemplate I declare a dropdown list as below:

                                    <asp:DropDownList ID="DropDownList6" runat="server" text='<%# Bind("District") %>'
                                    DataSourceID="SqlDataSource6" DataTextField="District"

How to get list of VALUES (not items) from a dropdownlist?


Hello all.  I see that dropdownlist has an "items" property to get the list of displayed items for a dropdown, but it doesn't seem to have an equivalent property for getting the "values" associated with the items.  For example, I may have a dropdown that displays "High", "Medium" and "Low", but returns values of "H", "M", "L".  How can I easily get that list of HML?

Thanks for any help!


DropDownList in DetailsView, invalid SelectedValue


I believe my question is not new here, but I think it is valuable because there are so many results from google with the 'dropdownlist in detailsview' as keywords.

Well, my question is described as below. (ASP.net and C#)

1)  I need a detailsview to add and edit record of table T1, which contains products information. T1 has a field 'catalog' which indicates the catalog of the product. All possible catalogs is stored in table T2. The simplified tables is described in 2)

2)  Simplified tables:

  • T1 fields: id, prodname,  catalog;  which is the datasource of the DetailsView.
  • T2 fields: id, catalog; which is the datasource of the dropdownlist in the detailsview.
  • all record of T1 have a catalog, which is picked up from T2.

3)  Functions I need are:

  • when detailsview in edit mode and insert mode, the field catalog should turns from a textbox to a dropdownlist which contains the catalogs stored in T2 .
  • when the item(catalog) of dropdownlist is selected and the 'update' button is clicked, the selected catalog (from T2) should replace the exist one of T1.

4)  My procedures to achieve the functions were:

  • drag and drop a detailsview control to a page, bind a datasource to it, en

How to bind the selectedvalue from asp.net dropdownlist to list



Sharepoint Designer 2007:

How can i bing data from asp.net contorl dropdownlist (selectedvalue) to list.

Thank you

jQuery: Styling DropDownList Alternating Items (Rows)

In the following example, I will show how you can style any asp:dropdownlist very easily.

The example demonstrates how you can change alternating row items background color, using the fadeTo() to add a nice touch in the dropdownlist. You can change alt rows with a couple lines.

Creating Sites/Lists/List Items under Current User Context in SharePoint By Using SPUserToken

Usually we do this by performing the action under RunWithElevatedPrivileges method and updating the listitem using SPListItem.SystemUpdate() method (see here). but this approach has its own flaws like (RunWithElevatedPrivileges will run under system account, we cannot use SystemUpdate for SPSite,SPWeb,SPList, since it runs under system we will "CreatedBy" by as SystemAccount).

Get pixel format, raw format, property id list and property items image in VB.net - C#.net.

n this simple article you will learn that how we can get pixel format, raw format, property id list and property items image in VB and C#.net.

Get Pixel Format:

Image consists of pixels to get the format of the pixel we have a property named pixel format. This property returns an enumeration of pixel format. This enumeration tells the pixel format.

To demonstrate make a window application. Drag one button and a picture box on form.

Now write the following code on Button click event:

Way of adding items in Drop Down List or List Box using Javascript

The article Way of adding items in Drop Down List or List Box using Javascript was added by raja.s on Sunday, June 06, 2010.

Hi,script type="text/javascript"> function AddItem(Text,Value) { // Create an Option object var opt = document.createElement("option"); // Add an Option object to Drop Down/List Box document.getElementById("DropDownList"

How to handle Active and inactive items in the dropdownlist?


It is a general ASP.NET questions. Many times some items in dropdownlist will become inactive (retired)or active again. It is easy to handle in the new records which use only currently active items. But how to handle the inactive items which need to be used to show history records. It bothered me a long time, not sure how to solve this problem efficiently.


How to Customize the Add Comment 'Items on this list require content approval...' notification in


WSS 3.0:

If content approval is turned on, the Add Comment section displays a fairly ugly notification. Is there any way I can customize that section through e.g. CSS or SPDesigner?

I'd like to change at least the text, and preferably the yellow exclamation image, and also the background if possible.

Add Items to List with BDC Column via Web Services

I really hope this is possible.  I am trying to add items to a list that have a BDC column as one of the fields.  Here is the code I am using in the Batch

batchElement.InnerXml = "<Method ID='1' Cmd='New'>" +  
"<Field Name='Title'>Hello World</Field>" +  
"<Field Name='bdc'>BDCIdentifier</Field>&

Display tooltip for Sharepoint list items


Hi All,

I am using MOSS 2007 and my requirement is to show tooltip when I hover the mouse over the title column for each item. I am planning on storing the tooltip string for each listitem in a seperate column. Is there a way to do it. I am sure there is. Any help is greatly appreciated.

Thanks in advance!




Delete list items en masse?

Is there a way to delete list items en masse from a SP list?  I am on MOSS 2007.  In order to use a particular site as a site template I had to save with content and I don't want the content.

dropdownlist javascript change items


I can't find solution for this problem for very long time:

I have dropdownlists in Gridview. I need to dinamicly change content of dropdown on client with javascript. Ok, I know to do that. But the problem is when I send data to server changes in dropdownlist does not see. On server I have  old items. How can I change items in dropdown on client with javascript and than see that items on sever when postback data?


dropdownlist bound to sqldatasource adds items instead of replacing on change



I have a series of dropdownlists on webform in ASP 4.0. The first drop down is filled upon load, and then when a user selects a value from that list, it populates the second dropdown. To accomplish this, I have a SQLdatasource with a parametersource of the first drop-down list control. This works great, except when a user changes their selection from the first drop down. It performs the query, but then adds the list of items to the ones that were already there from the previous selection, instead of replacing it with the new data. Here is the code:

 <asp:DropDownList ID="ddlMajor" runat="server" DataMember="DefaultView" 
      DataSourceID="SqlDataSource1" DataTextField="majortext" 
      DataValueField="majorkey" AppendDataBoundItems="True" AutoPostBack="True">
         <asp:ListItem Value="0">Select Major</asp:ListItem>
<asp:DropDownList ID="ddlReq" runat="server" DataMember="DefaultView" 
      DataSourceID="SqlDataSource2" DataTextField="req" DataValueField="admreqkey" 
            AppendDataBoundItems="True" AutoPostBack="True">
                <asp:ListItem Value="0">Sel

Need to remove databinding of DropdownList when another dropdown list changes


I have many controls on my form, but in particular, I have 2 dropdownlists.  1 dropdown list has 2 values, and each value controls what the second dropdownlist displays.  This is an edititemtemplate and both dropdowns have the selecteditem set via '<%# Bind("fieldname") #>' on page load.  

THe problem is, if I change the value of the first dropdown, it errors out because the second dropdwon has a bound value that is no longer acceptable. 

Can I cancel the bind of the second control, if the the first one is changed?  I would like to cancel the bind, and update the values by using a different datasource depending on the value of the first dropdown or hardcode the new values.



If Dropdown1 has a value of "A" for example Dropdown 2 Shows Values "1", "2", "3"

If Dropdown 1 has a value of "B" , Dropdown2 Shows Values "4", "5", "6".

It binds fine initially, but if I change Dropdown1 from A to B, I want Dropdown2 to show the new values, maybe with a default of "Select an Item" and not error out b/c it's attempts to bind a value of 1, 2, or 3.


Hope this makes sence, b/c I'm

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend