Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Radio button list in details view error

Status
Not open for further replies.

primagic

IS-IT--Management
Jul 24, 2008
476
GB
I have a details view and in the edit template I have a radio button list.

In view mode the field (Gender) is displaying a value from the database - Male.

When in edit mode, I have a radio button list whose datasource is a list which is derived from a table in the database. Male or Female.

However I get the error
Code:
'RadioButtonList1' has a SelectedValue which is invalid because it does not exist in the list of items.
Parameter name: value

Even though Male is an option as a radio button and is also the value stored in the field.

Any ideas
 
Sorry here is my code in asp.net

Code:
<asp:TemplateField HeaderText="Gender">
                                <ItemTemplate>
                                <asp:Label ID="lblGender" runat="server" Text='<%# Eval("Gender") %>' ></asp:Label>
                                </ItemTemplate>

                                <EditItemTemplate>
                                    
                                    <asp:RadioButtonList ID="RadioButtonList1" runat="server" 
                                        RepeatDirection="Horizontal" DataSourceID="GetGender" DataTextField="Gender" 
                                        DataValueField="Gender" SelectedValue='<%# Bind("Gender") %>' >
                                                                      </asp:RadioButtonList>
                                    
                                 
                                    <asp:SqlDataSource ID="GetGender" runat="server" 
                                        ConnectionString="<%$ ConnectionStrings:HostLinkConnectionString %>" 
                                        SelectCommand="SELECT [Gender] FROM [tblGenders]"></asp:SqlDataSource>
                                    
                                 
                                </EditItemTemplate>
                            </asp:TemplateField>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top