protected void OrganizationsGridView_Sorting(object sender, GridViewSortEventArgs e) { SetSortDirection(SortDireaction); if (GlobalLists.MemberOrganizations.Count > 1) { //Sort the data. var prop = typeof(MemberOrganizationModel).GetProperty(e.SortExpression); List <MemberOrganizationModel> sortedOrganizations; if (_sortDirection == "ASC") { sortedOrganizations = GlobalLists.MemberOrganizations.OrderBy(ll => prop.GetValue(ll, null)).ToList(); } else { sortedOrganizations = GlobalLists.MemberOrganizations.OrderByDescending(ll => prop.GetValue(ll, null)).ToList(); } OrganizationsGridView.DataSource = sortedOrganizations; OrganizationsGridView.DataBind(); SortDireaction = _sortDirection; int columnIndex = 0; foreach (DataControlFieldHeaderCell headerCell in OrganizationsGridView.HeaderRow.Cells) { if (headerCell.ContainingField.SortExpression == e.SortExpression) { columnIndex = OrganizationsGridView.HeaderRow.Cells.GetCellIndex(headerCell); } } OrganizationsGridView.HeaderRow.Cells[columnIndex].Controls.Add(sortImage); } }
private void renderOrganizationsGridView(string memberId) { HideMessage(); try { if (!String.IsNullOrEmpty(memberId)) { GlobalLists.MemberOrganizations = Members.GetMemberOrganizations(int.Parse(memberId.Trim())).ToList(); if (GlobalLists.MemberOrganizations.Count == 0) { //hide grids ValidateGridDisplayParameters(-1); ShowMessage(GlobalMessages.sMSG_NO_ORGANIZATION_WARNING); } else { OrganizationsGridView.DataSource = GlobalLists.MemberOrganizations; OrganizationsGridView.DataBind(); } } else { ShowMessage(String.Format(GlobalMessages.sMSG_EMPTYPARAM, "Member id")); } } catch (Exception ex) { logger.Error("Exception in uc_MemberDetail.renderOrganizationsGridView:" + ex.Message); ShowMessage(String.Format(GlobalMessages.sMSG_WARNING, ex.Message)); } }
protected void OrganizationsGridView_PageIndexChanging(object sender, GridViewPageEventArgs e) { OrganizationsGridView.DataSource = GlobalLists.MemberOrganizations; OrganizationsGridView.PageIndex = e.NewPageIndex; OrganizationsGridView.DataBind(); }