2011-03-18 64 views
0

我的代碼做的是EntityDataSource有一個Where參數綁定到第一個DropDownList,它填充第二個DropDownList,但是當第一個DDL更改時,EntityDataSource不會更改第二個DDL的值。刷新DropDownList EntityDataSource更改另一個DropDownList

值得一提的是在一個UpdatePanel中的ModalPopupExtender中。

也許有一種方法,只需將所有數據放在第二個DropDownList中,並根據第一個數據的值進行過濾......或類似的東西......所以不需要刷新數據。

<asp:DropDownList ID="PaqueteKitDropDownList" runat="server" DataSourceID="PaqueteEntityDataSource" 
       DataTextField="Nombre" DataValueField="ID_Paquete" /> 
      <asp:EntityDataSource ID="PaqueteEntityDataSource" runat="server" ConnectionString="name=CCEntities" 
       DefaultContainerName="CCEntities" EnableFlattening="False" EntitySetName="Paquetes"> 
      </asp:EntityDataSource> 
      <br /> 
      <asp:Label ID="Label66" AssociatedControlID="PlanKitDropDownList" runat="server" 
       Text="Plan:" /> 
      <asp:DropDownList ID="PlanKitDropDownList" runat="server" DataSourceID="PlanKitEntityDataSource" 
       DataTextField="Duracion" DataValueField="Costo" /> 
      <asp:EntityDataSource ID="PlanKitEntityDataSource" runat="server" ConnectionString="name=CCEntities" 
       DefaultContainerName="CCEntities" EnableFlattening="False" EntitySetName="Duracion_Plan" 
       Where="it.ID_Paquete == @ID" OrderBy="it.Duracion ASC"> 
       <WhereParameters> 
        <asp:ControlParameter DbType="Guid" Name="ID" ControlID="PaqueteKitDropDownList" 
         PropertyName="SelectedValue" /> 
       </WhereParameters> 
      </asp:EntityDataSource> 

回答

0

添加SelectedIndexChanged Event你的第一個DropDownList並重新綁定第二個

+0

有沒有什麼辦法去不服務器端? ...因爲這是一個modalpopupextender – sergioadh 2011-03-18 12:09:12

+0

以避免去服務器,你將需要使用不同的控件,支持客戶端綁定,而且,這是更重要的,你將需要一種機制來拉回數據,無需回發,使用ajax例如;服務器端方法有什麼問題? – 2011-03-18 12:12:51

+0

問題機智服務器端的方法是,我的dropdownlist是在modalpopupextender裏面,這將隱藏後去服務器端 – sergioadh 2011-03-18 17:25:35

0

調用:

PlanKitDropDownList.DataBind() 
相關問題