コード例 #1
0
        /// <summary>
        /// Binds the filter.
        /// </summary>
        private void BindFilter()
        {
            var sites = new SiteService().Queryable().OrderBy(s => s.Name).ToList();

            ddlSiteFilter.DataSource = sites;
            ddlSiteFilter.DataBind();
            ddlSiteFilter.Items.Insert(0, Rock.Constants.All.ListItem);
            ddlSiteFilter.Visible = sites.Any();
            ddlSiteFilter.SetValue(gContentListFilter.GetUserPreference("Site"));

            var item = ddlApprovedFilter.Items.FindByValue(gContentListFilter.GetUserPreference("Approval Status"));

            if (item != null)
            {
                item.Selected = true;
            }
            else
            {
                ddlApprovedFilter.SelectedIndex = 2;
            }

            int personId = 0;

            if (int.TryParse(gContentListFilter.GetUserPreference("Approved By"), out personId))
            {
                var personService = new PersonService();
                var person        = personService.Get(personId);
                if (person != null)
                {
                    ppApprovedByFilter.SetValue(person);
                }
            }
        }