private void SearchAndRenderGridView(Nullable <Int32> id, string firstName = "", string lastName = "", string email = "", string communityDisplayname = "") { using (MemberBL Members = new MemberBL()) { //Search by params GlobalLists.ListSaltMemberModel = Members.GetMembersBySearchParms(firstName.Trim(), lastName.Trim(), communityDisplayname.Trim()).ToList(); iRecordCount = GlobalLists.ListSaltMemberModel.Count(); if (iRecordCount > 0) { MemberDataGridView.DataSource = GlobalLists.ListSaltMemberModel; MemberDataGridView.DataBind(); if (iRecordCount == 1) { selectedMemberID = GlobalLists.ListSaltMemberModel[0].MemberID != null ? GlobalLists.ListSaltMemberModel[0].MemberID.ToString() : null; MemberDataGridView.SelectedIndex = 0; //select the only existing row GridViewRow selectedRow = MemberDataGridView.SelectedRow; selectedUserName = selectedRow.Cells[4].Text; RedirectToDetails(selectedMemberID, selectedUserName); } } else { ShowMessage(GlobalMessages.sMSG_NORECORDSFOUND); } } }
private void SearchPartialEmailAndRenderGridView(string email = "") { using (MemberBL Members = new MemberBL()) { //Search by params GlobalLists.ListMemberResults = Members.GetMembersBySearchParms(null, "", "", email, "").ToList(); iRecordCount = GlobalLists.ListMemberResults.Count(); if (iRecordCount > 0) { MemberDataGridView.DataSource = GlobalLists.ListMemberResults; MemberDataGridView.DataBind(); if (iRecordCount == 1) { selectedMemberID = GlobalLists.ListMemberResults[0].MemberID > 0 ? GlobalLists.ListMemberResults[0].MemberID.ToString() : null; MemberDataGridView.SelectedIndex = 0; //select the only existing row GridViewRow selectedRow = MemberDataGridView.SelectedRow; selectedUserName = selectedRow.Cells[4].Text; RedirectToDetails(selectedMemberID, selectedUserName); } this.displayRowCount(); } else { ShowMessage(GlobalMessages.sMSG_NORECORDSFOUND); } } }
protected void SortHelper(string sortExpression, int pageIndex) { if (GlobalLists.ListSaltMemberModel.Count >= 1) { List <SaltMemberModel> sortedOrganization; //Sort if possible SWD-6936 if (!string.IsNullOrEmpty(sortExpression)) { //Sort the data. var prop = typeof(SaltMemberModel).GetProperty(sortExpression); if (_sortDirection == "ASC") { sortedOrganization = GlobalLists.ListSaltMemberModel.OrderBy(lr => prop.GetValue(lr, null)).ToList(); sortImage.ImageUrl = descImagePath; //set global list to new sorted list GlobalLists.ListSaltMemberModel = sortedOrganization; } else { sortedOrganization = GlobalLists.ListSaltMemberModel.OrderByDescending(lr => prop.GetValue(lr, null)).ToList(); sortImage.ImageUrl = ascImagePath; //set global list to new sorted list GlobalLists.ListSaltMemberModel = sortedOrganization; } } else { //use the previous list sortedOrganization = GlobalLists.ListSaltMemberModel; } MemberDataGridView.DataSource = sortedOrganization; MemberDataGridView.PageIndex = pageIndex; MemberDataGridView.DataBind(); SortDireaction = _sortDirection; int columnIndex = 0; foreach (DataControlFieldHeaderCell headerCell in MemberDataGridView.HeaderRow.Cells) { if (headerCell.ContainingField.SortExpression == sortExpression) { columnIndex = MemberDataGridView.HeaderRow.Cells.GetCellIndex(headerCell); } } MemberDataGridView.HeaderRow.Cells[columnIndex].Controls.Add(sortImage); } }
protected void MemberDataGridView_PageIndexChanging(object sender, GridViewPageEventArgs e) { if (GlobalLists.ListSaltMemberModel.Count() > 0) { if (string.IsNullOrEmpty(_sortDirection)) { MemberDataGridView.DataSource = GlobalLists.ListSaltMemberModel; // ds.Tables[0]; MemberDataGridView.PageIndex = e.NewPageIndex; MemberDataGridView.DataBind(); } else { //Sort the data. SWD-6936 if (string.IsNullOrEmpty(sortExpression) && SaltShakerSession.MemberSortExpression != null) { sortExpression = SaltShakerSession.MemberSortExpression; } this.SortHelper(sortExpression, e.NewPageIndex); } } }