/// <summary>
        /// Binds the grid for defined types.
        /// </summary>
        private void gDefinedType_Bind()
        {
            var queryable = new DefinedTypeService().Queryable().Select(a =>
                                                                        new
            {
                a.Id,
                a.Category,
                a.Name,
                a.Description,
                FieldTypeName = a.FieldType.Name
            });

            string categoryFilter = tFilter.GetUserPreference("Category");

            if (!string.IsNullOrWhiteSpace(categoryFilter) && categoryFilter != Rock.Constants.All.Text)
            {
                queryable = queryable.Where(a => a.Category == categoryFilter);
            }

            SortProperty sortProperty = gDefinedType.SortProperty;

            if (sortProperty != null)
            {
                queryable = queryable.Sort(sortProperty);
            }
            else
            {
                queryable = queryable.OrderBy(a => a.Category).ThenBy(a => a.Name);
            }

            gDefinedType.DataSource = queryable.ToList();
            gDefinedType.DataBind();
        }
Beispiel #2
0
        /// <summary>
        /// Binds the grid for defined types.
        /// </summary>
        private void rGridType_Bind()
        {
            var queryable = new DefinedTypeService().Queryable().
                            Where(a => a.Category != "" && a.Category != null);

            if (ddlCategoryFilter.SelectedValue != "[All]")
            {
                queryable = queryable.
                            Where(a => a.Category == ddlCategoryFilter.SelectedValue);
            }

            SortProperty sortProperty = rGridType.SortProperty;

            if (sortProperty != null)
            {
                queryable = queryable.
                            Sort(sortProperty);
            }
            else
            {
                queryable = queryable.
                            OrderBy(a => a.Category);
            }

            rGridType.DataSource = queryable.ToList();
            rGridType.DataBind();
        }