示例#1
0
        /// <summary>
        /// Reads new values entered by the user for the field
        /// </summary>
        /// <param name="control">Parent control that controls were added to in the CreateEditControl() method</param>
        /// <param name="configurationValues">The configuration values.</param>
        /// <returns></returns>
        public override string GetEditValue(Control control, Dictionary <string, ConfigurationValue> configurationValues)
        {
            var    picker = control as DataViewsPicker;
            string result = null;

            var selectedValues = new List <int>();

            if (picker != null)
            {
                foreach (System.Web.UI.WebControls.ListItem li in picker.Items)
                {
                    if (li.Selected)
                    {
                        selectedValues.Add(li.Value.AsInteger());
                    }
                }

                var guids     = new List <Guid>();
                var dataViews = new DataViewService(new RockContext()).Queryable().Where(a => selectedValues.Contains(a.Id));

                if (dataViews.Any())
                {
                    guids = dataViews.Select(a => a.Guid).ToList();
                }

                result = string.Join(",", guids);
            }

            return(result);
        }