2013-02-27 64 views
0

一個GridTemplateColumn我有兩個GridTemplateColumn(一個或多個),每個包含一個radcombobox控件。當左組合框OnSelectedIndexChanged事件觸發,我需要根據左邊的新值重新填充正確的組合框。我似乎無法在的FindControl從事件的任何方式。如何找到radcombobox控件從不同GridTemplateColumn radcombobox控件OnSelectedIndexChanged事件

  <telerik:GridTemplateColumn HeaderText="CAKE Verticals" ItemStyle-Width="100px"> 
       <ItemTemplate> 
       </ItemTemplate> 
       <EditItemTemplate> 
        <telerik:RadComboBox runat="server" ID="RadComboBox_CakeVerticals" EnableLoadOnDemand="True" 
         OnItemsRequested="RadComboBox_CakeVerticals_ItemsRequested" AutoPostBack="true" 
         HighlightTemplatedItems="true" Height="140px" Width="220px" DropDownWidth="420px" 
         OnSelectedIndexChanged="RadComboBox_CakeVerticals_OnSelectedIndexChangedHandler"> 
        </telerik:RadComboBox> 
       </EditItemTemplate> 
      </telerik:GridTemplateColumn> 
      <telerik:GridTemplateColumn UniqueName="CakeColumns" HeaderText="CakeColumns" ItemStyle-Width="100px"> 
       <ItemTemplate> 
       </ItemTemplate> 
       <EditItemTemplate> 
        <telerik:RadComboBox runat="server" ID="RadComboBox_CakeColumns" EnableLoadOnDemand="True" 
         OnItemsRequested="RadComboBox_CakeColumns_ItemsRequested" AutoPostBack="true" 
         HighlightTemplatedItems="true" Height="140px" Width="220px" DropDownWidth="420px" 
         OnSelectedIndexChanged="RadComboBox_CakeColumns_OnSelectedIndexChangedHandler"> 
        </telerik:RadComboBox> 
       </EditItemTemplate> 
      </telerik:GridTemplateColumn> 

,並在CS

protected void RadComboBox_CakeVerticals_OnSelectedIndexChangedHandler(object sender, RadComboBoxSelectedIndexChangedEventArgs e) 
{ 
    RadComboBox combobox = (RadComboBox)RadGrid_Columns.FindControl("RadComboBox_CakeColumns"); 
    Session["verticalID"] = e.Value; 

    RCB_CAKE_Columns_Populate(e.Value, combobox); 

} 

問題是,組合框始終爲空。

回答

0

我解決了這個問題這樣

RadComboBox RCB_Verticals = sender as RadComboBox; 

    GridDataItem item = (GridDataItem)RCB_Verticals.NamingContainer; 

    RadComboBox combobox = (RadComboBox)item.FindControl("RadComboBox_CakeColumns"); 

這只是一個跟隨NamingContainer的層次結構,以行級的問題。

相關問題