RadGrid EditForm模板中的UpdatePanel或RadAjaxPanel不起作用

时间:2012-01-19 13:42:40

标签: c# asp.net ajax telerik

我有一个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>

你怎么能做这个工作?如果不可能,请提供不需要太多工作的替代方法。

1 个答案:

答案 0 :(得分:0)

你可以在网格上使用ItemDataBound事件来做,我已经展示了绑定country 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
    }

希望这有帮助。