Exemplo n.º 1
0
        /**
         * Read the page from the provider, set the sort mode, and update all of the pagination links
         * If page 1 is selected, don't show "First" and "Previous" links.
         * If last page selected, don't show "Next" and "Last" links.
         * If a page has no data, don't set a link to it.
         */
        public void SelectPage(int pageIndex)
        {
            _currentPageIndex = pageIndex;
            dgv.DataSource    = PagedDataProvider.GetPage(DataSetId, pageIndex, PageSize);
            foreach (DataGridViewColumn col in dgv.Columns)
            {
                col.SortMode = DefaultColumnSortMode;
            }
            SetPageDescription(GetPageDescription(pageIndex, PagedDataProvider.GetRecordCount(DataSetId)));
            int pageCount = GetPageCount(PagedDataProvider.GetRecordCount(DataSetId));

            if (PagedDataProvider.GetRecordCount(DataSetId) > PageSize)
            {
                lnkFirstPage.Visible    = (pageIndex != 1);
                lnkPreviousPage.Visible = (pageIndex != 1);
                SetPageLinks(pageIndex);
                lnkNextPage.Visible = (pageIndex != pageCount);
                lnkLastPage.Visible = (pageIndex != pageCount);
            }
            else
            {
                lnkFirstPage.Visible    = lnkLastPage.Visible = false;
                lnkPreviousPage.Visible = lnkNextPage.Visible = false;
                lnkPageA.Visible        = lnkPageB.Visible = lnkPageC.Visible = lnkPageD.Visible = lnkPageE.Visible = false;
            }
        }