I am having some trouble getting this code to work and I dont know what I missing, any help is greatly appreciated. I have a simple 9 question survey using asp.net, I am using an asp:formview with InsertItemTemplate. In the form I have a radiobuttonlist with yes no values, I have set the radio button list with AutoPostBack=True
<asp:FormView ID="FormView1" runat="server" DataSourceID="SqlDataSource1" Height="521px"
Width="700px" AllowPaging="True" DefaultMode="Insert" BorderStyle="Solid" BorderWidth="1" BackColor="ActiveBorder">
<InsertItemTemplate>
<table border="1">
<tr>
<td>
1.The IT hardware I use on a daily basis allows me to perform my job duties as needed.
</td>
<td>
<asp:RadioButtonList ID="RadioButtonList1" SelectedValue='<%# Bind("Q1") %>' runat="server" RepeatDirection="Horizontal" Width="40px" AutoPostBack="true">
<asp:ListItem Value='yes'>Yes</asp:ListItem>
<asp:ListItem Value='No'>No</asp:ListItem>
</asp:RadioButtonList>
</td>
</tr>
<tr id="comment1" runat="server" visible="false">
<td colspan="2">If no please explain<br />
<asp:TextBox ID="Q1CommentsTextBox" runat="server" Rows="4" TextMode="MultiLine" Text='<%# Bind("Q1Comments") %>'>
</asp:TextBox>
</td>
</tr>
On the backend I am using the following code
If RadioButtonList1.SelectedItem.Value = "no" Then
Comment1.Visible = True
Else
Comment1.Visible = False
End If
The page loads and inserts fine, however when I select No the page reloads but does not show the textbox required. I have also tried the following code
<asp:FormView ID="FormView1" runat="server" DataSourceID="SqlDataSource1" Height="521px"
Width="700px" AllowPaging="True" DefaultMode="Insert" BorderStyle="Solid" BorderWidth="1" BackColor="ActiveBorder" onselectedindexchanged="RadioButtonList1_SelectedIndexChanged">
[code]
Protected Sub RadioButtonList1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButtonList1.SelectedIndexChanged
If IsPostBack Then
If RadioButtonList1.SelectedItem.Value = "no" Then
Comment1.Visible = True
Else
Comment1.Visible = False
End If
'End If
End Sub
Please help, I cannot figure out what I am missing