private int AttendeesDataBind()
    {
        List <Person> people;
        int           GrandTotal = 0;

        if (!ShowActiveCheck.Checked)
        {
            people = CD.GetAttendees(Convert.ToInt32(hfOccurrence.Value));
        }
        else
        {
            people = CD.GetAttendees(Convert.ToInt32(hfOccurrence.Value)).Where(x => x.Checkout.Date == new DateTime(1900, 1, 1)).ToList();
        }

        TotalAttendeesLabel.Text  = people.Where(x => x.PersonType == Arena.Enums.OccurrenceAttendanceType.Person && x.Checkin >= DateTime.Today && x.Checkout == DateTime.Parse("1/1/1900")).Count().ToString();
        TotalVolunteersLabel.Text = people.Where(x => x.PersonType == Arena.Enums.OccurrenceAttendanceType.Leader && x.Checkin >= DateTime.Today && x.Checkout == DateTime.Parse("1/1/1900")).Count().ToString();
        GrandTotal           = people.Where(x => x.Checkin >= DateTime.Today && x.Checkout == DateTime.Parse("1/1/1900")).Count();
        GrandTotalLabel.Text = GrandTotal.ToString();


        AttendeesList.DataSource = people;
        AttendeesList.DataBind();

        return(GrandTotal);
    }
    protected void AttendeesList_Sorting(object sender, GridViewSortEventArgs e)
    {
        List <Person> people;

        this.GridSortExpression = e.SortExpression;

        if (AttendeesList.DataSource == null)
        {
            this.AttendeesDataBind();
        }

        people = (List <Person>)AttendeesList.DataSource;

        IEnumerable _data = people;

        Type dataSourceType = _data.GetType();

        Type dataItemType = typeof(object);

        if (dataSourceType.HasElementType)
        {
            dataItemType = dataSourceType.GetElementType();
        }
        else if (dataSourceType.IsGenericType)
        {
            dataItemType = dataSourceType.GetGenericArguments()[0];
        }
        else if (_data is IEnumerable)
        {
            IEnumerator dataEnumerator = _data.GetEnumerator();

            if (dataEnumerator.MoveNext() && dataEnumerator.Current != null)
            {
                dataItemType = dataEnumerator.Current.GetType();
            }
        }

        //var fieldType = dataItemType.GetProperty(e.SortExpression);

        object sorterObject = null;

        Type sorterType = null;

        // We'll handle things like LINQ to SQL differently by passing the love
        // on to the provider.
        PropertyInfo property = dataItemType.GetProperty(e.SortExpression.Split('\u0020')[0]);

        sorterType = typeof(Arena.Custom.SECC.Checkin.Sort.GenericSorter <,>).MakeGenericType(dataItemType, property.PropertyType);

        sorterObject = Activator.CreateInstance(sorterType);

        AttendeesList.DataSource = sorterType.GetMethod("Sort", new Type[] { dataSourceType, typeof(string), typeof(SortDirection) })
                                   .Invoke(sorterObject, new object[] { _data, e.SortExpression.Split('\u0020')[0], e.SortExpression.EndsWith("ASC") ? SortDirection.Ascending : SortDirection.Descending });

        if (e.SortExpression.EndsWith("ASC"))
        {
            e.SortExpression = e.SortExpression.Replace("ASC", "DESC");
        }
        else
        {
            e.SortExpression = e.SortExpression.Replace("DESC", "ASC");
        }

        foreach (DataControlField dcf in AttendeesList.Columns)
        {
            if (dcf.SortExpression.StartsWith(e.SortExpression.Split('\u0020')[0]))
            {
                dcf.SortExpression = e.SortExpression;
                break;
            }
        }

        AttendeesList.DataBind();
    }