2012-01-19 35 views
0

我有一個RadGrid,我在其中使用EditForm FormTemplate。RadGrid中的UpdatePanel或RadAjaxPanel EditForm模板不工作

裏面有一些列表(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> 

你怎麼能做出這樣的工作?如果不可能,請給出不需要太多工作的替代方法。

回答

0

可以使用網格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 
    } 

希望這會有所幫助。

+0

我會再次訪問Telerik(工作時)時檢查此內容。 – Aidiakapi