Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hi,

 

I'm having a bit of trouble with the DropDownList control, on a bit data type. I have one screen for inserting records, and another for updating. The insert works fine, but my update screen keeps crashing with the message "lstBluetooth has a SelectedValue which is invalid because it does not exist in the list of items. Parameter name: value"

 

The code I have for the dropdown is:

               <asp:TemplateField HeaderText="Bluetooth">
                   <EditItemTemplate>
                       <asp:DropDownList ID="lstBluetooth" runat="server" Width="100px" 
                                         DataValueField="Bluetooth" SelectedValue='<%# Bind("Bluetooth") %>'>
                           <asp:ListItem Text="True" Value="true"/>
                           <asp:ListItem Text="False" Value="false"/>
                       </asp:DropDownList>
                   </EditItemTemplate>
                   <ItemTemplate>
                      <asp:Label ID="lblBluetooth" runat="server" Text='<%# Eval("Bluetooth") %>' />
                   </ItemTemplate>
               </asp:TemplateField>

I've tried changing the Value field for the 2 ListItems to 0 and 1 (as this is all that will ever be retrieved from the field Bluetooth which is defined as a bit in the database).

 

The above code for the DropDownList works fine on my insert page. The template field above exists in a DetailsView control, which used a PageDataSource for binding.

 

Any ideas on how to get this working?

What if the Hokey-Pokey IS what it's all about?

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...