0

我有两个 GridTemplateColumn(s),每个都包含一个 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);

}

问题是组合框始终为空。

4

1 回答 1

0

我解决了这样的问题

    RadComboBox RCB_Verticals = sender as RadComboBox;

    GridDataItem item = (GridDataItem)RCB_Verticals.NamingContainer;

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

这只是遵循 NamingContainer 的层次结构到行级别的问题。

于 2013-02-28T17:38:14.880 回答