Click here to Skip to main content
15,881,600 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

In my application I am using the gridview. In that I am using the Radiobutton list with two list item value "Y" and "N". In my form I want to check the condition for that radiobutton list. If it is "Y" the radiobutton to be selected and if it is "N" it will be selected. If it is Empty No need to select the Radiobuttonlist. My problem is When I am binding the data it Showing the error that the radiobutton list value is present for string.empty but it is not available in the list of item. How to solve this problem. Here is the code

XML
<asp:TemplateField HeaderText="Status">
                                        <ItemTemplate>
  <asp:RadioButtonList ID="rdbConsultantInvolved" runat="server" CssClass="css_radiobutton_list"
SelectedValue='<%#DataBinder.Eval(Container.DataItem ,"SolutionEngineerConfirmId")%>' RepeatDirection="Horizontal"
AppendDataBoundItems="True">
<asp:ListItem Value="N" Text="Open" ></asp:ListItem>
<asp:ListItem Value="Y" Text="Confirmed"></asp:ListItem>
</asp:RadioButtonList>

                                        </ItemTemplate>
                                        <HeaderStyle HorizontalAlign="center" VerticalAlign="Middle" />
                                        <ItemStyle />
                                    </asp:TemplateField>




Thanks
Posted
Updated 8-Jan-12 19:57pm
v2
Comments
Wayne Gaylard 9-Jan-12 1:56am    
You should tag your question with the GUI library you are using i.e WinForms of WPF.

1 solution

Hi,

In your case you should use the
C#
OnDataBinding
event, and manually bind your data.

Or you could add another item to your list
HTML
<asp:listitem value="" text="" style="display: none" xmlns:asp="#unknown" />
and it will handle your empty values from database.


Hope this helps.
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900