コード例 #1
0
        protected void ProcessDropDownAttribute(FieldTemplateMetadata metadataForProperty, object container, Type containerType)
        {
            var dropdownAttribute = metadataForProperty.Attributes.OfType<DropDownListAttribute>();

            if (!dropdownAttribute.Any())
            {
                return;
            }

            var sourceProperty = dropdownAttribute.First().SourceProperty;
            var sourceList = (IEnumerable<SelectListItem>)containerType.InvokeMember(sourceProperty, BindingFlags.GetProperty, null, container, null);

            if (sourceList != null)
            {
                var selectedItem = sourceList.FirstOrDefault(i => i.Value == metadataForProperty.Model.ToString());

                if (selectedItem != null)
                {
                    selectedItem.Selected = true;
                }
            }

            dropdownAttribute.First().List = sourceList;
        }
コード例 #2
0
        protected void ProcessDropDownAttribute(FieldTemplateMetadata metadataForProperty, object container, Type containerType)
        {
            var dropdownAttribute = metadataForProperty.Attributes.OfType <DropDownListAttribute>();

            if (!dropdownAttribute.Any())
            {
                return;
            }

            var sourceProperty = dropdownAttribute.First().SourceProperty;
            var sourceList     = (IEnumerable <SelectListItem>)containerType.InvokeMember(sourceProperty, BindingFlags.GetProperty, null, container, null);

            if (sourceList != null)
            {
                var selectedItem = sourceList.FirstOrDefault(i => i.Value == metadataForProperty.Model.ToString());

                if (selectedItem != null)
                {
                    selectedItem.Selected = true;
                }
            }

            dropdownAttribute.First().List = sourceList;
        }
コード例 #3
0
        protected int GetOrder(FieldTemplateMetadata metadataForProperty)
        {
            var orderAttribute = metadataForProperty.Attributes.OfType<OrderAttribute>();

            return orderAttribute.Any() ? orderAttribute.First().Order : _StartOrder++;
        }
コード例 #4
0
        protected int GetOrder(FieldTemplateMetadata metadataForProperty)
        {
            var orderAttribute = metadataForProperty.Attributes.OfType <OrderAttribute>();

            return(orderAttribute.Any() ? orderAttribute.First().Order : startOrder++);
        }