I have also altered the Dbase column to a bit 1 or 0, and set the default value to 0. Taken the Not Null option off as well, but it is STILL returning the same error.
I have even changed it to char(9) and put the default value as Awaiting, still no luck.
Thought I would try radio buttons instead, and it still pulls the same error, what's going on?
Just to follow up on a previous suggestion I ran into a similar problem getting this error message. I did have to go back to my SQL Server 2008 table and modify columns that corresponded to the dropdownlist items. I think perhaps the slightest difference
such as column length or format such as char or nchar could cause problems. Also using dropdownlists to insert we often require some sort of default option on a pre-select. When it comes to edits in a GridView I think we only want to pre-select existing values.
When copying code from forms and placing it in the GridView Template we must think about what is happening and make our adjdustments such as not including a detault value that has no real value in a column of our target table. It is possible that on an insert
when a listitem on a dropdownlist is left untouched hence sent as a default value that code behind overrides and selects a valid value before the SQL insert is done. Could end up being a little tricky.
ajith_tintin
Member
6 Points
3 Posts
Re: 'DropDownList1' has a SelectedValue which is invalid because it does not exist in the list of...
May 13, 2009 08:54 AM|LINK
hey friends!!!
here
is theajith_tintin
Member
6 Points
3 Posts
Re: 'DropDownList1' has a SelectedValue which is invalid because it does not exist in the list of...
May 13, 2009 08:54 AM|LINK
hey friends
here are some gideliness for solving this problem.
Check whether the Value field of the dropdown is same as the database.column name
Check whether that columns contain null values in that column.
Thank you
dst101
Member
244 Points
202 Posts
Re: 'DropDownList1' has a SelectedValue which is invalid because it does not exist in the list of...
May 18, 2009 02:27 PM|LINK
I too have the same problem, my code:
<asp:TemplateField HeaderText="Decide:" SortExpression="Decide">
<ItemTemplate>
<asp:Label ID="Label2" runat="server" Text='<%# Bind("Decide") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:DropDownList DataTextField="Decide" DataValueField="Decide" ID="DropDownList2" Runat="server" SelectedValue='<%# Bind("Decide") %>' AppendDataBoundItems="true" >
<asp:ListItem>------------------------</asp:ListItem>
<asp:ListItem Value="Accept">Accept Job</asp:ListItem>
<asp:ListItem Value="Reject">Reject Job</asp:ListItem>
</asp:DropDownList>
</EditItemTemplate>
<InsertItemTemplate>
<asp:TextBox ID="TextBoxDecide" runat="server" Text='<%# Bind("Decide") %>'></asp:TextBox>
</InsertItemTemplate>
</asp:TemplateField>
Now if I change the EditItemTemplate to <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("Decide") %>'></asp:TextBox> it works fine......WTF
I have also another Template that uses the same idea, and it works fine!
All the rows in the DBASE have records in it, so can anyone give me a heads up on why this isn't working?
cheryl01
Member
8 Points
25 Posts
Re: 'DropDownList1' has a SelectedValue which is invalid because it does not exist in the list of...
May 18, 2009 06:05 PM|LINK
Have you tried adding a default value in the field in the table of your database?
dst101
Member
244 Points
202 Posts
Re: 'DropDownList1' has a SelectedValue which is invalid because it does not exist in the list of...
May 19, 2009 09:28 AM|LINK
Yeah I put in 'Awaiting' as a default value. But still the same error?
dst101
Member
244 Points
202 Posts
Re: 'DropDownList1' has a SelectedValue which is invalid because it does not exist in the list of...
May 19, 2009 11:21 AM|LINK
I have tried this on another DetailsView as well, and it's pulling the same error.
I can't understand it at all [scratchHead]
dst101
Member
244 Points
202 Posts
Re: 'DropDownList1' has a SelectedValue which is invalid because it does not exist in the list of...
May 20, 2009 09:29 AM|LINK
I have also altered the Dbase column to a bit 1 or 0, and set the default value to 0. Taken the Not Null option off as well, but it is STILL returning the same error.
I have even changed it to char(9) and put the default value as Awaiting, still no luck.
Thought I would try radio buttons instead, and it still pulls the same error, what's going on?
bofcarbon1
Member
53 Points
21 Posts
Re: 'DropDownList1' has a SelectedValue which is invalid because it does not exist in the list of...
Jun 24, 2009 06:10 PM|LINK
Just to follow up on a previous suggestion I ran into a similar problem getting this error message. I did have to go back to my SQL Server 2008 table and modify columns that corresponded to the dropdownlist items. I think perhaps the slightest difference such as column length or format such as char or nchar could cause problems. Also using dropdownlists to insert we often require some sort of default option on a pre-select. When it comes to edits in a GridView I think we only want to pre-select existing values. When copying code from forms and placing it in the GridView Template we must think about what is happening and make our adjdustments such as not including a detault value that has no real value in a column of our target table. It is possible that on an insert when a listitem on a dropdownlist is left untouched hence sent as a default value that code behind overrides and selects a valid value before the SQL insert is done. Could end up being a little tricky.
tab container
Muhammad way
Member
22 Points
54 Posts
Re: 'DropDownList1' has a SelectedValue which is invalid because it does not exist in the list of...
Jul 01, 2009 02:43 PM|LINK
the first post was in 2004
the last one was in 2009
I'm facing the same porblem and until now there is no official solution from MS ?!
lars-erik
Member
292 Points
56 Posts
Re: 'DropDownList1' has a SelectedValue which is invalid because it does not exist in the list of...
Jul 06, 2009 11:15 AM|LINK
Hi all!
Here's a forgiving DropDownList allowing you to bind to invalid values. Hope it can help someone. :)
http://community.omnicom.no/blogs/lea/archive/2009/07/06/tired-of-quot-has-a-selectedvalue-which-is-invalid-because-it-does-not-exist-in-the-list-of-items-quot.aspx
L-E
MCTS: Web / MCPD