Rock.Web.UI.Controls.RockDropDownList.LoadViewState C# (CSharp) Method

LoadViewState() protected method

Loads the previously saved view state of the T:System.Web.UI.WebControls.DetailsView control.
protected LoadViewState ( object savedState ) : void
savedState object An that represents the state of the -derived control.
return void
        protected override void LoadViewState( object savedState )
        {
            base.LoadViewState( savedState );
            var savedAttributes = ViewState["ItemAttributes"] as List<Dictionary<string, string>>;
            int itemPosition = 0;

            // make sure the list has the same number of items as it did when ViewState was saved
            if ( savedAttributes.Count == this.Items.Count )
            {
                // don't bother doing anything if nothing has any attributes
                if ( savedAttributes.Any( a => a.Count > 0 ) )
                {
                    foreach ( var item in this.Items.OfType<ListItem>() )
                    {
                        var itemAttributes = savedAttributes[itemPosition++];
                        foreach ( var a in itemAttributes )
                        {
                            item.Attributes.Add( a.Key, a.Value );
                        }
                    }
                }
            }
        }