0

What my code does is that the EntityDataSource has a Where Parameter tied to the first DropDownList and it populates the second DropDownList, but when the first DDL changes, the EntityDataSource doesn't change the values of the second DDL.

Worth mentioning this is inside a ModalPopupExtender which is inside an UpdatePanel.

Maybe there is a way in just putting all the data in the second DropDownList and filter it depending on the value of the first one... or something like that... so there's no need of refreshing the data.

<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>
sergioadh
  • 1,461
  • 1
  • 16
  • 24

2 Answers2

0

add SelectedIndexChanged Event to your first DropDownList and rebind the second one

Kris Ivanov
  • 10,476
  • 1
  • 24
  • 35
  • is there any way to not go server side? ... because this is inside a modalpopupextender – sergioadh Mar 18 '11 at 12:09
  • to avoid going to server you will need to use different controls that support client side binding, also, which is more critical, you will need a mechanism to pull the data without post back, using ajax for example; what is wrong with server side approach? – Kris Ivanov Mar 18 '11 at 12:12
  • the problem wit server side approach is that my dropdownlists are inside a modalpopupextender which will hide after going server side – sergioadh Mar 18 '11 at 17:25
0

Invoke:

PlanKitDropDownList.DataBind()
Tisho
  • 8,320
  • 6
  • 44
  • 52
Sarzniak
  • 297
  • 4
  • 10