Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Hiding tablerow based on radiobuttonlist selection

Reply
Thread Tools

Hiding tablerow based on radiobuttonlist selection

 
 
chief21 chief21 is offline
Junior Member
Join Date: Apr 2009
Posts: 1
 
      04-09-2009
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

Code:
<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>
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

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
Any help is greatly appreciated, I am sure it is something simple I am missing but I cant see it.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Focus/selection on RadioButton or RadioButtonList after postback BizEd ASP .Net 1 10-02-2007 09:51 PM
Cannot get radioButtonList selection VR ASP .Net Web Controls 2 06-29-2005 02:54 PM
Setting RadioButtonList selection =?Utf-8?B?ZGhucml2ZXJzaWRl?= ASP .Net 2 05-10-2005 12:48 PM
showing and hiding something based on selection made middletree Javascript 4 01-14-2005 04:26 PM
Simply Displaying Information From TableRow frank ASP .Net 0 07-11-2003 04:10 PM



Advertisments