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
290
How to clear webdropdowns
posted

Could someone please help:  I have added a function to clear all webdropdowns and webdatepicker's on my page.  For some reason I cannot get the WebDropdowns ( which are just in divs or my datapickers to clear.  What is really weird with the Webdropdowns is that I have two other dropdowns that are not in the Panel "pnlDrops" and are in UpdatePanels.  Those will clear by setting the .SelectedItemIndex = 0 and setting dropdown.items.clear.

Note:  The button that I use to clear the webdropdown and webdatepicker is contained within an asp.net UpdatePanel, Updatemode="Always".

Dave.Thanks

Dave.

Here is my source:

  <asp:Panel ID="pnlDrops" runat="server">
            <table width="80%" cellpadding="0" cellspacing="0">
                <tr>
                    <td align="left">
                        <asp:Label ID="lblWarehouse" runat="server" Text="WareHouse:" Font-Size="Small"></asp:Label>
                        <ig:WebDropDown ID="ddlWarehouse" runat="server" Width="110px" EnableClosingDropDownOnSelect="false"
                            DropDownContainerWidth="110px" DropDownContainerHeight="200px" EnableMultipleSelection="true"
                            MultipleSelectionType="Keyboard" EnableDropDownAsChild = "false">
                        </ig:WebDropDown>
                    </td>
                </tr>
            </table>
        </asp:Panel>



                        <ig:WebDatePicker runat="server" ID="wdpStartDate" StyleSetName="Default" Width="100px">
                        </ig:WebDatePicker>

Here is the code that I have been using:

Dim webDD As WebDropDown
            For Each c As Control In pnlDrops.Controls
                If TypeOf c Is WebDropDown Then
                    webDD = CType(c, WebDropDown)
                    webDD.SelectedItemIndex = 0
                End If
            Next

' Clear Date Controls.
            wdpStartDate.Text = ""
            wdpStartDate.Value = wdpStartDate.MinValue
            wdpEndDate.Text = ""
            wdpEndDate.Value = wdpEndDate.MinValue

Parents
No Data
Reply
  • 8736
    posted

    Hello,

    Thanks for the mark up and the details provided. I was able to find WebDropDown using the below line of code:

    Dim wdd As WebDropDown = Me.pnlDrops.FindControl("ddlWarehouse")

    Once I have instance of WebDropDown I was able to clear it using the below line of code in button click event.

    wdd.CurrentValue = String.Empty

    Also make sure the WebDropDown and button is in the same update panel.

    Hope this helps.

    Thanks,

    Bhadresh

Children