protected void TodoContentGridView_Sorting(object sender, GridViewSortEventArgs e) { if (combinedContentItems.Count > 1) { //Sort the data. var prop = typeof(ContentModel).GetProperty(e.SortExpression); SortDirection direction = GetSortDirection(e.SortExpression); if (direction == SortDirection.Ascending) { combinedContentItems = combinedContentItems.OrderBy(ll => prop.GetValue(ll, null)).ToList(); } else { combinedContentItems = combinedContentItems.OrderByDescending(ll => prop.GetValue(ll, null)).ToList(); } TodoContentGridView.DataSource = combinedContentItems; TodoContentGridView.DataBind(); int columnIndex = 0; foreach (DataControlFieldHeaderCell headerCell in TodoContentGridView.HeaderRow.Cells) { if (headerCell.ContainingField.SortExpression == e.SortExpression) { columnIndex = TodoContentGridView.HeaderRow.Cells.GetCellIndex(headerCell); } } TodoContentGridView.HeaderRow.Cells[columnIndex].Controls.Add(sortImage); } }
private void renderTodoContentGridView() { HideMessage(); TodoContentGridView.DataSource = combinedContentItems; TodoContentGridView.DataBind(); TodoContentGridView.SelectedIndex = -1; }
protected void TodoContentGridView_PageIndexChanging(object sender, GridViewPageEventArgs e) { TodoContentGridView.DataSource = combinedContentItems; TodoContentGridView.PageIndex = e.NewPageIndex; TodoContentGridView.DataBind(); }