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

How to handle SelectedIndexChanged of a RadComboBox in a NestedViewTemplate

4 Answers 269 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Christian
Top achievements
Rank 1
Christian asked on 23 Jan 2012, 04:31 PM
Hi,

I have a RadComboBox as an element in a NestedViewTemplate of a RadGrid. There are also several labels in the nested view whose text I would like to change dynamically depending on the selected item of the combobox.

I tried:
RadComboBox combo = (RadComboBox)CustomerGrid.MasterTableView.Items[0].ChildItem.FindControl("cardsCombo");

from within cardsCombo_SelectedIndexChanged to try and get hold of it, to no avail (I guess I'm looking in the wrong place).

So my question is, how do I implement SelectedIndexChanged functionality from within the nested view?

Any help would be greatly appreciated.

Cheers,
Christian

4 Answers, 1 is accepted

Sort by
0
Accepted
Jayesh Goyani
Top achievements
Rank 2
answered on 23 Jan 2012, 06:55 PM
Hello Christian,

protected void RadComboBox1_SelectedIndexChanged(object sender, RadComboBoxSelectedIndexChangedEventArgs e)
        {
            RadComboBox RadComboBox1 = sender as RadComboBox;
            GridDataItem item = RadComboBox1.NamingContainer as GridDataItem;
            Label Label1 = item.FindControl("Label1") as Label;
            Label1.Text = "Test";
        }
<telerik:GridTemplateColumn>
                       <ItemTemplate>
                           <telerik:RadComboBox ID="RadComboBox1" runat="server" AutoPostBack="true" OnSelectedIndexChanged="RadComboBox1_SelectedIndexChanged">
                           </telerik:RadComboBox>
                           <asp:Label ID="Label1" runat="server"></asp:Label>
                       </ItemTemplate>
                        
                   </telerik:GridTemplateColumn>


Thanks,
Jayesh Goyani
0
Christian
Top achievements
Rank 1
answered on 24 Jan 2012, 10:33 AM
Hi,

Thanks, this works for finding the combo, but not for finding the labels. Any ideas how to do this?

Cheers,
Christian
0
Accepted
Shinu
Top achievements
Rank 2
answered on 24 Jan 2012, 10:52 AM
Hello,

Try the following code.
C#:
protected void RadComboBox1_SelectedIndexChanged(object sender, RadComboBoxSelectedIndexChangedEventArgs e)
{
 RadComboBox combo = sender as RadComboBox;
 GridNestedViewItem item = (GridNestedViewItem)combo.NamingContainer;
 Label lbl = (Label)item.FindControl("Label2");
}

-Shinu.
0
Christian
Top achievements
Rank 1
answered on 24 Jan 2012, 10:56 AM
That's the one.

Thanks Guys,
Christian
Tags
Grid
Asked by
Christian
Top achievements
Rank 1
Answers by
Jayesh Goyani
Top achievements
Rank 2
Christian
Top achievements
Rank 1
Shinu
Top achievements
Rank 2
Share this question
or