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.
Unfortunately, activation email could not send to your email. Please try again.

Cascading Dropdownlist values Undefined

Thread ID:

Created:

Updated:

Platform:

Replies:

128601 Jan 31,2017 09:12 AM Feb 1,2017 07:52 AM ASP.NET Web Forms 1
loading
Tags: DropDownList
Levi Leonards
Asked On January 31, 2017 09:12 AM

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

Prince Oliver [Syncfusion]
Replied On February 1, 2017 07:52 AM

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   


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;