using System;
using System.Data;
using System.Data.SqlClient ;

using System.Configuration;
using System.Collections;
using System.Collections.Generic ;

using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class DataListWithPager : System.Web.UI.Page
{
    PagedDataSource pds;

    protected void Page_Load(object sender, EventArgs e)
    {
        pds= new PagedDataSource();
        pds.AllowPaging = true;
        pds.PageSize = 3;
        pds.DataSource = GetList();

        if (!IsPostBack)
        {
            MessageTotal.Text = GetPageCount().ToString();
         
            PageTotal.Text = pds.PageCount.ToString();
            PageCurrent.Text = (pds.CurrentPageIndex + 1).ToString();

            Binding();

            for (int i = 1; i <= pds.PageCount; i++)
                DropDownList1.Items.Add(i.ToString());
        }

    }

    private List<Categories> GetList()
    {
        List<Categories> list = new List<Categories>();
        
     

        return list;    
    }

    private  int GetPageCount()
    {
        int tempInt =2;

        return tempInt;

    }


    public void Binding()
    {
    }
  
    protected void Previous_Click(object sender, EventArgs e)
    {
        pds.CurrentPageIndex = Convert.ToInt32(PageCurrent.Text) - 2;

        PageCurrent.Text = (pds.CurrentPageIndex + 1).ToString();
        Binding();
    }

    protected void Next_Click(object sender, EventArgs e)
    {
        pds.CurrentPageIndex = Convert.ToInt32(PageCurrent.Text);

        PageCurrent.Text = (pds.CurrentPageIndex + 1).ToString();
        Binding();
    }

    protected void First_Click(object sender, EventArgs e)
    {
        pds.CurrentPageIndex = 0;
        PageCurrent.Text = "1";
        Binding();
    }

    protected void Last_Click(object sender, EventArgs e)
    {
        PageCurrent.Text = PageTotal.Text;
        pds.CurrentPageIndex = pds.PageCount - 1;
        Binding();
    }

    protected void Go_Click(object sender, EventArgs e)
    {
        pds.CurrentPageIndex = Convert.ToInt32(DropDownList1.SelectedValue) - 1;
        Binding();
    }





}
