public void GridBindOnSorting(string SortColumn, string SortDirection, int CurrentPage) { try { SortExpression = SortColumn; gvSortDirection = SortDirection; DataSet dsPharmacies = (DataSet)Session["PharmacySearch"]; DataView dv = dsPharmacies.Tables["Pharmacy"].DefaultView; dv.Sort = "" + SortColumn + " " + SortDirection + ""; GridViewSearchPharmacies.DataSource = dv; GridViewSearchPharmacies.DataBind(); int totalRows = 0; int totalRecordsPerPage = 0; if (dsPharmacies.Tables["TotalRecords"].Rows[0]["TotalRecords"] != null) { totalRows = Convert.ToInt32(dsPharmacies.Tables["TotalRecords"].Rows[0]["TotalRecords"].ToString()); } totalRecordsPerPage = dsPharmacies.Tables["Pharmacy"].Rows.Count; if (CurrentPage == 0) { LinkButtonPrevious.Enabled = false; if (totalRows > PageSize) { LinkButtonNext.Enabled = true; } else { LinkButtonNext.Enabled = false; } } else { LinkButtonPrevious.Enabled = true; if (totalRecordsPerPage < PageSize) { LinkButtonNext.Enabled = false; } else { LinkButtonNext.Enabled = true; } } } catch (Exception ex) { throw (ex); } }
public void GridBind(string PharmacyName, string Address, string City, string State, string Zip, string Phone, string Fax, int PharmacyId, string SureScriptIdentifier, string Specialty, int startRowIndex, int endRowIndex, int CurrentPage, int PageSize) { objClientMedications = new Streamline.UserBusinessServices.ClientMedication(); try { pharmacyId = PharmacyId; pharmacyName = PharmacyName; address = Address; city = City; state = State; zip = Zip; phone = Phone; fax = Fax; sureScriptIdentifier = SureScriptIdentifier; //SortExpression = sortExpression; //StartrowIndex = startrowIndex; //MaximumRows = maximumRows; //startrowIndex = CurrentPage * 1 + 1; //endRowIndex = PageSize * CurrentPage + 1; using (DataSet dataSetPharmacies = objClientMedications.GetSearchPharmacies(PharmacyName.Trim(), Address.Trim(), City.Trim(), State.Trim(), Zip.Trim(), Phone.Trim(), Fax.Trim(), PharmacyId, SureScriptIdentifier.Trim(), Specialty.Trim(), startRowIndex, endRowIndex)) { GridViewSearchPharmacies.DataSource = dataSetPharmacies.Tables["Pharmacy"]; GridViewSearchPharmacies.DataBind(); Session["PharmacySearch"] = dataSetPharmacies; int totalRows = 0; int totalRecordsPerPage = 0; if (dataSetPharmacies.Tables["TotalRecords"].Rows[0]["TotalRecords"] != null) { totalRows = Convert.ToInt32(dataSetPharmacies.Tables["TotalRecords"].Rows[0]["TotalRecords"].ToString()); } totalRecordsPerPage = dataSetPharmacies.Tables["Pharmacy"].Rows.Count; int value = Convert.ToInt32((totalRows) / PageSize); if ((totalRows) % PageSize != 0 && value >= 0) { LabelTotalPages.Text = Convert.ToString(value + 1) + ")"; } else { LabelTotalPages.Text = Convert.ToString(value) + ")"; } if (CurrentPage == 0) { LinkButtonPrevious.Enabled = false; if (totalRows > PageSize) { LinkButtonNext.Enabled = true; } else { LinkButtonNext.Enabled = false; } LabelPageNumber.Text = "(Page " + (CurrentPage + 1).ToString() + " of"; } else { LinkButtonPrevious.Enabled = true; if (totalRows <= (PageSize * (CurrentPage + 1))) { LinkButtonNext.Enabled = false; } else { LinkButtonNext.Enabled = true; } LabelPageNumber.Text = "(Page " + (CurrentPage + 1).ToString() + " of"; } } //GridViewSearchPharmacies.DataSourceID = "ObjectDataSourcePharmacy"; //GridViewSearchPharmacies.DataBind(); } catch (Exception ex) { throw (ex); } }