Solved

dropdown list

Posted on 2016-08-15
6
46 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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
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 …
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

706 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

20 Experts available now in Live!

Get 1:1 Help Now