private void ChangeCurrentPage() { try { if (this.cmboFunctionField != null) { Log.Timer.Start(); Dgv.CurrentPage = Convert.ToInt32(this.tbCurrentPage.Text); if (Dgv.CurrentPage > Dgv.LastPage) { Dgv.CurrentPage = Dgv.LastPage; this.tbLastPage.Text = Dgv.LastPage.ToString(); } else if (Dgv.CurrentPage < 1) { Dgv.CurrentPage = 1; this.tbCurrentPage.Text = "1"; } // table starts with row 1 not row 0 if (string.IsNullOrWhiteSpace(Dgv.OrderByClause)) { // no current sortstate, sort on default which is rowid asc Dgv.Sort(this.dgData, Dgv.PageRowCount * (Dgv.CurrentPage - 1)); } else { // use the user's SortState Dgv.Sort(this.dgData, Dgv.PageRowCount * (Dgv.CurrentPage - 1)); } Status("Jumped to page " + Dgv.CurrentPage.ToString("#,##0") + " in " + Log.Timer.ElapsedTime().ToString()); } } catch (Exception Ex) { this.tbCurrentPage.Text = Dgv.CurrentPage.ToString(); Status(Ex.Message); return; } }
public TablePage(GridViewLoadfile gridview, LoadfileBase loadfile) { InitializeComponent(); Dgv = gridview; // Collect the fieldnames added to the grid this.cmboFunctionField.ItemsSource = Dgv.FieldNamesAsDisplayed; this.cmboFunctionField.DataContext = Dgv; this.tbPageRowCount.Text = Dgv.PageRowCount.ToString(); this.tbLastPage.Text = Dgv.LastPage.ToString(); this.tblTotalRowCount.Text = Dgv.TotalRowCount.ToString("#,##0") + " rows"; // wire up the paging events now that we are ready for the user this.tbLastPage.TextChanged += tbLastPage_TextChanged; this.tbCurrentPage.TextChanged += tbCurrentPage_TextChanged; Dgv.Sort(this.dgData, 0); // the loadfile object this.Loadfile = loadfile; }