Solved

dropdown list

Posted on 2016-08-15
6
48 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

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…
In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

867 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

24 Experts available now in Live!

Get 1:1 Help Now