我有两个GridTemplateColumn,每个都包含一个RadCombobox。当左组合框OnSelectedIndexChanged事件触发时,我需要根据左侧的新值重新填充右组合框。我不能以任何方式从事件中看到FindControl。
<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 :(得分:0)
我解决了这个问题
RadComboBox RCB_Verticals = sender as RadComboBox;
GridDataItem item = (GridDataItem)RCB_Verticals.NamingContainer;
RadComboBox combobox = (RadComboBox)item.FindControl("RadComboBox_CakeColumns");
只需遵循NamingContainer的层次结构,即行级别。