This is a migrated thread and some comments may be shown as answers.

Show Hide RadComboBox depending on RadioButtonList Selected Value

3 Answers 255 Views
Grid
This is a migrated thread and some comments may be shown as answers.
gc_0620
Top achievements
Rank 1
gc_0620 asked on 17 Nov 2010, 06:07 AM
Folks,

Is it possible to show/hide RadComboBox depending on the RadioButtionListSelected Value? For example In RadioButtonList1_SelectedIndexChanged event, if my RadioButtonList1's selected Value = "1", show RadcomboBox (CountryName), else hide the RadComboBox.  Both My RadioButtonList and ComboBox are within EditTemplate of RadGrid.

Below is my code.

Thanks

<telerik:GridTemplateColumn DataField="rblLIST" HeaderText="rbl" UniqueName="rBL">
                        <EditItemTemplate>
                         
                               <asp:RadioButtonList ID="RadioButtonList1" runat="server"  AutoPostBack = "true"
                                onselectedindexchanged="RadioButtonList1_SelectedIndexChanged" 
                                RepeatDirection="Horizontal">
                                    <asp:ListItem Text="Yes" Value="1"></asp:ListItem>
                <asp:ListItem Text="No" Value="2"></asp:ListItem>
  
                            </asp:RadioButtonList>     
                              
                             
                        </EditItemTemplate>
                    </telerik:GridTemplateColumn>
                      
                    <telerik:GridTemplateColumn DataField="CountryName" HeaderText="Country" UniqueName="CountryName">
                      
                        <ItemTemplate>
                            <asp:Label ID="Label3" runat="server" Text='<%# Eval("CountryName") %>'></asp:Label>
                        </ItemTemplate>
                        <EditItemTemplate>
                            <telerik:RadComboBox ID="rcbCountries"  
                                runat="server" 
                                AutoPostBack="true"
                                Skin="Vista"                                         
                                DataTextField="Name" 
                                DataValueField="CountryID">                                
                            </telerik:RadComboBox>
                        </EditItemTemplate>
                    </telerik:GridTemplateColumn>


3 Answers, 1 is accepted

Sort by
0
gc_0620
Top achievements
Rank 1
answered on 17 Nov 2010, 08:34 PM

Hi,

I was able to solve it by reading the solution provided by Shinu In this thread. The issue I had is very identical.

The only question I have how I can use NamingContainer property if the RadioButtonList and the RadCombo in childTable GridTableView EditTemplate as opposed to MasterTableView  EditTemplate?   Can I use something like e.Item.OwnerTableView.Name == "Detail" in RadioButton_SelectedIndexChanged event? Please refer to attached .

Thanks

GC_0620

 

0
Martin
Telerik team
answered on 22 Nov 2010, 12:26 PM
Hello GC_0620,

In the RadioButtonList's SelectedIndexChanged event handler you can not use the arguments ("e" parameter) to get a reference to the item in which the list resides. Instead, you should use a slightly modified approach:

protected void RadioButtonList1_SelectedIndexChanged(Object sender, EventArgs e)
{
    RadioButtonList list = sender as RadioButtonList;
    GridEditableItem item = list.NamingContainer as GridEditableItem;
    if (item.OwnerTableView.Name == "DetailTable1")
    {
        RadComboBox combo = item.FindControl("rcbCountries") as RadComboBox;
        combo.Visible = list.SelectedValue == "1";
    }
}

I hope this helps.

Regards,
Martin
the Telerik team
Browse the vast support resources we have to jumpstart your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
0
gc_0620
Top achievements
Rank 1
answered on 23 Nov 2010, 11:42 PM
Thanks Martin, your solution works. Have a happy Thanksgiving!!!

Regards,

gc_0620
Tags
Grid
Asked by
gc_0620
Top achievements
Rank 1
Answers by
gc_0620
Top achievements
Rank 1
Martin
Telerik team
Share this question
or