Example #1
0
 /// <summary>
 /// Gets the values entered into the edit controls generated by the <see cref="GetEditControls"/> method and sets the <see cref="P:IHasAttributes.AttributeValues"/> of
 /// the <see cref="IHasAttributes"/> object
 /// </summary>
 /// <param name="parentControl">The parent control.</param>
 /// <param name="item">The item.</param>
 public static void GetEditValues(Control parentControl, IHasAttributes item)
 {
     if (item.Attributes != null)
     {
         foreach (var category in item.Attributes)
         {
             foreach (var attribute in category.Value)
             {
                 Control control = parentControl.FindControl(string.Format("attribute_field_{0}", attribute.Id.ToString()));
                 if (control != null)
                 {
                     Rock.Core.DTO.AttributeValue value = new Core.DTO.AttributeValue();
                     value.Value = attribute.FieldType.Field.ReadValue(control);
                     item.AttributeValues[attribute.Key] = new KeyValuePair <string, List <Rock.Core.DTO.AttributeValue> >(attribute.Name, new List <Rock.Core.DTO.AttributeValue>()
                     {
                         value
                     });
                 }
             }
         }
     }
 }
Example #2
0
 /// <summary>
 /// Gets the values entered into the edit controls generated by the <see cref="GetEditControls"/> method and sets the <see cref="P:IHasAttributes.AttributeValues"/> of 
 /// the <see cref="IHasAttributes"/> object
 /// </summary>
 /// <param name="parentControl">The parent control.</param>
 /// <param name="item">The item.</param>
 public static void GetEditValues( Control parentControl, IHasAttributes item )
 {
     if ( item.Attributes != null )
         foreach ( var category in item.Attributes )
             foreach ( var attribute in category.Value )
             {
                 Control control = parentControl.FindControl( string.Format( "attribute_field_{0}", attribute.Id.ToString() ) );
                 if ( control != null )
                 {
                     Rock.Core.DTO.AttributeValue value = new Core.DTO.AttributeValue();
                     value.Value = attribute.FieldType.Field.ReadValue( control );
                     item.AttributeValues[attribute.Key] = new KeyValuePair<string, List<Rock.Core.DTO.AttributeValue>>( attribute.Name, new List<Rock.Core.DTO.AttributeValue>() { value } );
                 }
             }
 }