Rock.Web.UI.Controls.ItemPicker.SelectedValueAsInt C# (CSharp) Method

SelectedValueAsInt() public method

Gets the selected value as an integer, returning NULL if the selected value is "0"
public SelectedValueAsInt ( bool noneAsNull = true ) : int?
noneAsNull bool if set to true [none as null].
return int?
        public int? SelectedValueAsInt( bool noneAsNull = true )
        {
            if ( string.IsNullOrWhiteSpace( ItemId ) )
            {
                return null;
            }

            int result = ItemId.AsInteger();
            if ( noneAsNull )
            {
                if ( result == Constants.None.Id )
                {
                    return null;
                }
            }

            return result;
        }