AjaxControlToolkit.ComboBox.LoadPostData C# (CSharp) Méthode

LoadPostData() protected méthode

protected LoadPostData ( string postDataKey, NameValueCollection postCollection ) : bool
postDataKey string
postCollection System.Collections.Specialized.NameValueCollection
Résultat bool
        protected virtual bool LoadPostData(string postDataKey, NameValueCollection postCollection)
        {
            if(!Enabled)
                return false;

            var postCollectionValues = postCollection.GetValues(HiddenFieldControl.UniqueID);
            if(postCollectionValues == null)
                return false;

            var newSelectedIndex = Convert.ToInt32(postCollectionValues[0], CultureInfo.InvariantCulture);
            EnsureDataBound();

            if(newSelectedIndex == -2 && (DropDownStyle == ComboBoxStyle.Simple || DropDownStyle == ComboBoxStyle.DropDown)) {
                var newText = postCollection.GetValues(TextBoxControl.UniqueID)[0];
                var eventArgs = new ComboBoxItemInsertEventArgs(newText, ItemInsertLocation);
                OnItemInserting(eventArgs);

                if(!eventArgs.Cancel)
                    InsertItem(eventArgs);
                else
                    TextBoxControl.Text = (SelectedIndex < 0) ? String.Empty : SelectedItem.Text;

            } else if(newSelectedIndex != SelectedIndex) {
                SelectedIndex = newSelectedIndex;
                return true;
            }

            return false;
        }