RadGrid EditForm模板中的UpdatePanel或RadAjaxPanel不工作

本文关键字:RadAjaxPanel 工作 UpdatePanel EditForm RadGrid | 更新日期: 2023-09-27 18:20:52

我有一个RadGrid,在其中我使用的是EditForm FormTemplate。

里面有一个列表(RadComboBox),里面有一些公司。当用户选择其中一家公司时,它应该用所有位置的列表填充另一个RadComboBox。

起初,我使用UpdatePanel,然后使用RadAjaxPanel进行了尝试。两者都不起作用。

这是一个精简版:

<FormTemplate>
    <table>
        <telerik:RadAjaxPanel runat="server">
            <tr>
                <td>
                    Company
                </td>
                <td>
                    <telerik:RadComboBox ID="rcbCompany" runat="server" Width="250px" ValidationGroup="NewResource"
                        DataTextField="C_Name" DataValueField="Bedrijf_ID" AppendDataBoundItems="true"
                        OnSelectedIndexChanged="rcbCompany_OnSelectedIndexChanged">
                    </telerik:RadComboBox>
                </td>
            </tr>
            <tr>
                <td>
                    Locatie
                </td>
                <td>
                    <telerik:RadComboBox ID="rcbLocation" runat="server" Width="250px" ValidationGroup="NewResource"
                        DataTextField="location" DataValueField="Location_ID" AppendDataBoundItems="true" />
                </td>
            </tr>
        </telerik:RadAjaxPanel>
    </table>
</FormTemplate>

你怎么能做到这一点?如果这是不可能的,请给出不需要太多工作的替代方法。

RadGrid EditForm模板中的UpdatePanel或RadAjaxPanel不工作

您可以使用网格上的ItemDataBound事件来完成,我已经展示了绑定国家drpdown:的示例

protected void gridLocation_ItemDataBound(object sender, GridItemEventArgs e)
    {
            if (e.Item.IsInEditMode)
            {
                GridEditableItem item = (GridEditableItem)e.Item;
                if (!(e.Item is IGridEditableColumn))
                {
                    RadComboBox combo = (RadComboBox)item.FindControl("dropdwnCountry");
                    LoadCountries(combo);
                }
            }
    }
protected void LoadCountries(RadComboBox combo)
    {
        //your defn goes here
    }

要级联下拉,您可以参加国家的onchange事件,如:

protected void country_selected(object sender, RadComboBoxSelectedIndexChangedEventArgs e)
    {
            RadComboBox combo = (RadComboBox)sender;
            GridEditableItem edit = (sender as RadComboBox).NamingContainer as GridEditableItem;
            RadComboBox combos = (RadComboBox)edit.FindControl("dropdwnState");
            LoadStates(combos, combo.SelectedValue);
    }
 protected void LoadStates(RadComboBox combo,string countryId)
    {
        //your defn goes here
    }

希望这能有所帮助。