Skip to content

How use Paging DataGird in WinForm

AnhTin Bui

Asked Feb 20, 2006, 6:31 PM EST1 answer
Share
LinkedInX
I have a Question. can u answer to Me I want Paging for DataGird. i use Dataset fill Data on DataGird i intend Select 10 rows in Dataset to row =1 ---> row =10 or .... Select Data rely on number Rows in Database can u move solve this problem to me. The Best if u give Example to me So I think to syntex Select Top but it unable. I try to use syntax ds.table["name"].Select , ds.table["name"].Rows['number'] but unSuccessful it dose'nt get 10 rows in dataset thanks

1 Answer

Know the answer? Post it. Somebody with the same question will find it here.

  • Anwar Buchoo
    0

    Go to the Properties window of the DataGrid (Alt+Enter)

    Set AllowPaging=true
    Set PageSize to the number of records you want to display per page, i.e. 10.

    You can additionally change the PagerStyle by setting (amongst others) the Mode to NumericPages, default being NextPrev.

    Now to handle the event, add the event PageIndexChanged.  Inside the event add something like that:

      ItemsGrid.CurrentPageIndex = e.NewPageIndex

      ' Rebind the data to refresh the DataGrid control. 
      ItemsGrid.DataSource = // set this to your coming data source, e.g. a DataView
      ItemsGrid.DataBind()

    Hope it helps.


    0