void bs_PositionChanged(object sender, EventArgs e) { int pos = ((BindingSource)sender).Position + 1; string q = s.GetPagingQuery(pg.GetStartRowNum(pos), pg.GetEndRowNum(pos), false); DataTable dt = DataProvider.ExecuteDt(q); DataSource = dt; }
public void SetPagedDataSource(SQLQuery s, BindingNavigator bnav) { this.s = s; int count = DataProvider.ExecuteCount(s.CountQuery); pg = new Paging(count, 5); bnav.BindingSource = pg.BindingSource; pg.BindingSource.PositionChanged += new EventHandler(bs_PositionChanged); //first page string q = s.GetPagingQuery(pg.GetStartRowNum(1), pg.GetEndRowNum(1), true); DataTable dt = DataProvider.ExecuteDt(q); DataSource = dt; }