Solved

dropdown list

Posted on 2016-08-15
6
53 Views
Last Modified: 2016-08-17
Hi,

I am using this in ASP.net

                    <asp:DropDownList ID="FollowUpUser" runat="server" DataSourceID="SqlDataSource1" DataTextField="username" DataValueField="username" AppendDataBoundItems="true">                                                                          
                     </asp:DropDownList>            
                     
                    <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:conn %>"
                    SelectCommand="SELECT username from users where system='Asset' order by username">
                    </asp:SqlDataSource>  


I have checked that the value is in the table, but I am getting

'FollowUpUser' has a SelectedValue which is invalid because it does not exist in the list of items.
Parameter name: value

Is there a way to avoid this error?  thanks
0
Comment
Question by:mcrmg
  • 3
  • 3
6 Comments
 
LVL 18

Accepted Solution

by:
Rajar Ahmed earned 500 total points
ID: 41756349
Try adding by default value :

<asp:DropDownList ID="FollowUpUser" runat="server" DataSourceID="SqlDataSource1" DataTextField="username" DataValueField="username" AppendDataBoundItems="true">                                                                          
<asp:ListItem Text="Select" Value="" />
</asp:DropDownList>   

Open in new window

0
 

Author Comment

by:mcrmg
ID: 41756370
Thanks for the quick reply, I am still getting the same error. Am I missing something>?  thanks


                    <label style="font-weight:bold">Follow Up User:</label>&nbsp;                                                                                                                          
                    <asp:DropDownList ID="FollowUpUser" runat="server" DataSourceID="SqlDataSource1" DataTextField="username" DataValueField="username" AppendDataBoundItems="true">                                                                          
                    <asp:ListItem Text="Select" Value="" />
                    </asp:DropDownList>           
                     
                    <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:conn %>"
                    SelectCommand="SELECT username from users where system='Asset' order by username">
                    </asp:SqlDataSource> 

Open in new window

0
 

Author Comment

by:mcrmg
ID: 41756437
thank you
0
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

 
LVL 18

Expert Comment

by:Rajar Ahmed
ID: 41756445
Your code perfectly worked in my machine .

Are you performing any codebehind stuff with dropdownlist values if so please post that code too.

Meanwhile take a look at the below link which its kinda same issue you are mentioning:
http://stackoverflow.com/questions/19770207/dropdownlist-has-a-selectedvalue-which-is-invalid-because-it-does-not-exist-in-t
0
 
LVL 18

Expert Comment

by:Rajar Ahmed
ID: 41758899
Any update ?
0
 

Author Closing Comment

by:mcrmg
ID: 41759205
thank you
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

816 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now