• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 61
  • Last Modified:

dropdown list

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
mcrmg
Asked:
mcrmg
  • 3
  • 3
1 Solution
 
Rajar AhmedConsultantCommented:
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
 
mcrmgAuthor Commented:
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
 
mcrmgAuthor Commented:
thank you
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
Rajar AhmedConsultantCommented:
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
 
Rajar AhmedConsultantCommented:
Any update ?
0
 
mcrmgAuthor Commented:
thank you
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now