예제 #1
0
 private void DataPager_PageChanging(object sender, PageChangingEventArgs e)
 {
     if (!GotoPage(e.NewPageIndex))
     {
         e.IsCancel = true;
     }
 }
예제 #2
0
        /// <summary>
        /// 页码更改
        /// </summary>
        /// <param name="pageIndex"></param>
        internal void OnPageChanging(int pageIndex)
        {
            if (pageIndex < 1)
            {
                pageIndex = 1;
            }
            if (pageIndex > this.PageCount)
            {
                pageIndex = this.PageCount;
            }

            var oldPageIndex = this.PageIndex;
            var newPageIndex = pageIndex;
            var eventArgs    = new PageChangingEventArgs()
            {
                OldPageIndex = oldPageIndex, NewPageIndex = newPageIndex
            };

            if (this.PageChanging != null)
            {
                this.PageChanging(this, eventArgs);
            }
            if (!eventArgs.IsCancel)
            {
                this.PageIndex = newPageIndex;
                if (this.PageChanged != null)
                {
                    this.PageChanged.Invoke(this, new PageChangedEventArgs()
                    {
                        CurrentPageIndex = this.PageIndex
                    });
                }
            }
        }