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
595
WebDropDown - Cannot clear selected item Client-Side
posted

I've got the following code for clearing the selections and resetting the WebDropDown server side:


            foreach (Infragistics.Web.UI.ListControls.DropDownItem item in WebDropDown1.Items)
            {
                if (item.Selected)
                {
                    item.Selected = false;
                }
            }

            this.WebDropDown1.CurrentValue = "Please select...";

This works, although is very complex considering there should be an easy way to do this... i.e. WebDropDown1.SelectedIndex = -1 like a normal WinForm control. Even WebDropDown1.SelectedItems.Clear() would be better.

I'm now trying to do the same thing Client-Side. This is the code I have that doesn't work:

        function Reset()
        {    
            var dropDown = $find('<%=WebDropDown1.ClientID %>');
            var selectedList = dropDown.get_selectedItems();
            for (var i = 0; i< selectedList.length; i++)
            {
                selectedList[i].set_selected(false);
            }
            dropDown.set_currentValue("Please select...", false);
        }

How can this be done client-side?

Parents Reply Children