We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Cascading Dropdownlist values Undefined

I have two cascading dropdownlists. When the first dropdownlist is selected, the data source for the second is updated.
This works the first time through the page, but if the first dropdown list is changed, then the values in the second dropdown list are all undefined.

ASPX code:
<asp:Content ID="Content3" ContentPlaceHolderID="MainContent" runat="server"> 
        Data Set:
  <ej:DropDownList ID="DatasetDropDownList1" runat="server" WatermarkText="Select A DataSet">
   <Items>
    <ej:DropDownListItem runat="server" Text="Circuits" Value="Circuits" />
    <ej:DropDownListItem runat="server" Text="Deficiencies" Value="Deficiencies" />
   </Items>
  </ej:DropDownList>
        <br/>
  Facility:
  <ej:DropDownList ID="FacilityDropDownList" runat="server" WatermarkText="Select A Facility" DataTextField="FACILITYID"
   DataValueField="FACILITYID">
  </ej:DropDownList>
    <asp:SqlDataSource ID="FacilityDropDownDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:EC_WEB %>"
        ProviderName="<%$ ConnectionStrings:EC_WEB.ProviderName %>"
        SelectCommand="SELECT ID AS FACILITYID FROM [\\Celery\published\web_test].WebFacilities WHERE (WEB_AUTH_KEY = ?)">
        <SelectParameters>
            <asp:SessionParameter Name="WEB_AUTH_KEY" SessionField="WebKey" Type="String" />
        </SelectParameters>
    </asp:SqlDataSource>
</asp:Content>


VB Code:
Private Sub DatasetDropDownList1_ValueSelect(sender As Object, e As DropdownListEventArgs) Handles DatasetDropDownList1.ValueSelect
 If e.Value = "Circuits" Then
  Dim data As DataView = DirectCast(FacilityDropDownDataSource.[Select](New DataSourceSelectArguments()), DataView)
  Dim dt As DataTable = data.Table
  FacilityDropDownList.DataSource = dt
  FacilityDropDownList.DataBind()
 ElseIf e.Value = "Deficiencies" Then
  Dim data As DataView = DirectCast(FacilityDropDownDataSource.[Select](New DataSourceSelectArguments()), DataView)
  Dim dt As DataTable = data.Table
  Dim workRow As DataRow = dt.NewRow()
  workRow(0) = "-SELECT ALL-"
  dt.Rows.InsertAt(workRow, 0)
  FacilityDropDownList.DataSource = dt
  FacilityDropDownList.DataBind()
 End If
End Sub

Attachment: Dropdownlist__Undefined_4ddf7276.zip

1 Reply

PO Prince Oliver Syncfusion Team February 1, 2017 12:52 PM UTC

Hi Levi,  

Thanks for contacting Syncfusion support.  

We were unable to run your exact code without your database, so we recreated your scenario from the code you shared and prepared a sample as per your requirement to cascade dropdownlists with SQL Datasource.  

Refer to the following link for the sample:  

Regards,  
Prince   


Loader.
Live Chat Icon For mobile
Up arrow icon