Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1495
Cascading Web Drop Downs
posted

I have some cascading dropdowns.  DD2 and DD3 are in update panels.  DD1 triggers DD2 which then triggers DD3.   When they pick DD1, my selected index is correct.  When they pick DD2, DD1 and DD2 selected index is correct.  When they pick DD3, I lose the selected index in DD2.  If I have DD3 set to autopost back, the value blanks out in the DD2.  IF I have DD3 NOT set to auto post back, DD2 remains selected properly but when they hit the save button DD2's selected index is -1 but DD1 and DD3 are fine.  Code below.

 


<table>
  <tr>
      <td class="label" align="right">Asset Class:</td>
      <td>
          <ig:WebDropDown runat="server" ID="ddAssetClass" Width="250px" DisplayMode="DropDownList"
                      EnableViewState="false" Button-ImageUrl="~/images/igdd_DropDownButton.png"
                      CssClass="normalClass" CurrentValue=""
                      DropDownContainerHeight="200px">
                      <ClientEvents />
                      <AutoPostBackFlags SelectionChanged="On" />
          </ig:WebDropDown>
      </td>
  </tr>
  <tr>
      <td class="label" align="right">Asset Sub Class:</td>
      <td>
          <asp:UpdatePanel ID="UpdatePanel1" runat="server">
              <Triggers>
                  <asp:AsyncPostBackTrigger ControlID="ddAssetClass" />
              </Triggers>
              <ContentTemplate>
                      <ig:WebDropDown runat="server" ID="ddSubClass" Width="250px" DisplayMode="DropDownList"
                                  EnableViewState="false" Button-ImageUrl="~/images/igdd_DropDownButton.png"
                                  CssClass="normalClass" CurrentValue=""
                                  DropDownContainerHeight="200px">
                                  <ClientEvents />
                                  <AutoPostBackFlags SelectionChanged="On" />
                      </ig:WebDropDown>   
              </ContentTemplate>
          </asp:UpdatePanel>  
      </td>
  </tr>
  <tr>
      <td class="label" align="right">Asset Nomanclature:</td>
      <td>
          <asp:UpdatePanel ID="UpdatePanel2" runat="server">
              <Triggers>
                  <asp:AsyncPostBackTrigger ControlID="ddSubClass" />
              </Triggers>
              <ContentTemplate>
                      <ig:WebDropDown runat="server" ID="ddNomanclature" Width="250px" DisplayMode="DropDownList"
                                  EnableViewState="false" Button-ImageUrl="~/images/igdd_DropDownButton.png"
                                  CssClass="normalClass" CurrentValue=""
                                  DropDownContainerHeight="200px">
                      </ig:WebDropDown>  
              </ContentTemplate>
          </asp:UpdatePanel>
      </td>
  </tr>
</table>

IN PAGE LOAD .........
                                                   
' fill asset class dd
ddAssetClass.DataSource = objLogBook.ReturnAssetClassList(WorkCenterID.Value)
ddAssetClass.TextField = "AssetName"
ddAssetClass.ValueField = "AssetClassID"
' before databinding, grab the item they had selected
iItemIndex = ddAssetClass.SelectedItemIndex
ddAssetClass.DataBind()

If (iItemIndex > 0) Then
    ddAssetClass.SelectedItemIndex = iItemIndex
    strAssetClassValue = ddAssetClass.SelectedValue
End If

'async panel asset sub dropdown
If strAssetClassValue > "" Then
    ddSubClass.DataSource = objLogBook.ReturnAssetSubList(strAssetClassValue)
    ddSubClass.TextField = "AssetName"
    ddSubClass.ValueField = "AssetClassID"
    ' before databinding, grab the item they had selected
    iItemIndex2 = ddSubClass.SelectedItemIndex
    ddSubClass.DataBind()
End If

If (iItemIndex2 > 0) Then
    ddSubClass.SelectedItemIndex = iItemIndex2
    strSubClassValue = ddSubClass.SelectedValue
End If

'async panel asset nomanclature dropdown
If strSubClassValue > "" Then
    ddNomanclature.DataSource = objLogBook.ReturnAssetSubList(strSubClassValue)
    ddNomanclature.TextField = "AssetName"
    ddNomanclature.ValueField = "AssetClassID"
    ' before databinding, grab the item they had selected
    iItemIndex3 = ddNomanclature.SelectedItemIndex
    ddNomanclature.DataBind()
End If


If (iItemIndex3 > 0) Then
    ddSubClass.SelectedItemIndex = iItemIndex3
End If