Link to home
Start Free TrialLog in
Avatar of mcrmg
mcrmg

asked on

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
ASKER CERTIFIED SOLUTION
Avatar of Rajar Ahmed
Rajar Ahmed
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of mcrmg
mcrmg

ASKER

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

Avatar of mcrmg

ASKER

thank you
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
Any update ?
Avatar of mcrmg

ASKER

thank you