Click here to Skip to main content
13,089,610 members (57,604 online)
Rate this:
Please Sign up or sign in to vote.
Hey guys, I have this problem from few weeks. I have a form with radio button list 1.Active 2.Inactive as list items .
In another page I have dataformview to search and edit above filled data. If user did not select any option from the radiobutton list during submission and tries to edit null data in form view it throws an error saying "RadioButtonList' has a SelectedValue which is invalid because it does not exist in the list of items" .How should I approach for this problem. I am using varchar as datatype for radiobutton. Also which datatype would be best for radiobutton (to save data and bind).Do I need to set default value for radiobutton list? Please help me. Appreciate your response.
Here is the sample code of radiobutton submission
<asp:RadioButtonList ID="RadioButtonList1" runat="server" AutoPostBack="True"
                   style="text-align: left; font-size: medium;" RepeatDirection="Horizontal"
                   RepeatLayout="Flow" AppendDataBoundItems="True">
                   <asp:ListItem Text="Active">Active</asp:ListItem>
                   <asp:ListItem Text = "Inactive">Inactive</asp:ListItem>

Here is the code for edit item template of formview
<asp:RadioButtonList ID="RadioButtonList3" runat="server"
                            SelectedValue = '<%# Bind("stat") %>'
                            Width="300px" TabIndex="3">
                            <asp:ListItem Text="Active" />
<asp:ListItem Text="Inactive" />

Note; stat is the column name for radiobutton list
Posted 25-Sep-12 12:12pm
Updated 25-Sep-12 12:13pm

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

employ javascript validation before heading to server side code....
sreeharshakakarla 25-Sep-12 23:45pm
Thanks for reply. Could you please elaborate your idea? I can use required field validator at client side but I don't want radio button list to be required field. I want it to take null value as another item such that users can change their selected value in edit item template . This link contains a similar problem but I am not sure of what datatype to actually use for radiobutton list so that I could find null values also.
shabari7 25-Sep-12 23:53pm
modify your stored procedure according to ur requirement

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web04 | 2.8.170813.1 | Last Updated 25 Sep 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100