Gridview; enabling paging programatically

Can't work out how to do this.

My code below displays the gridview correctly, but hundreds of records on one page. I figured I'd adjust the page size = 5 but no change...

So, I think I need to enable paging....how do I do this in the code?

Thx
Dim conn As New SqlConnection("Data Source=DAODEVBOX;Initial Catalog=suds_prototype;User ID=sa;Password=***")
 
        Dim ds As New Data.DataSet()
        Dim da As New SqlDataAdapter("select * from Centers", conn)
        da.Fill(ds, "Centres")
 
        grdDisplay.DataSource = ds.Tables("Centres")
        grdDisplay.DataBind()
        grdDisplay.Visible = True
        grdDisplay.PageSize = 5

Open in new window

bdb12Asked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
Guy Hengel [angelIII / a3]Connect With a Mentor Billing EngineerCommented:
you have to set the AllowPaging to true
you ahve to set the pagesize and the AllowPaging BEFORE you bind the grid



        Dim ds As New Data.DataSet()
        Dim da As New SqlDataAdapter("select * from Centers", conn)
        da.Fill(ds, "Centres")
 
        grdDisplay.AllowPaging=True
        grdDisplay.PageSize = 5 
        grdDisplay.DataSource = ds.Tables("Centres")
        grdDisplay.DataBind()
        grdDisplay.Visible = True

Open in new window

0
 
bdb12Author Commented:
Ah, I didn't see that function...thx for the super fast response
0
 
bdb12Author Commented:
Hi Angel3, thx for your help with this.

I have another problem tho where the page numbers dont work when clicked, I started a new question here

http://www.experts-exchange.com/Programming/Languages/.NET/Visual_Basic.NET/Q_23125416.html

Any chance you can check it out?
0
All Courses

From novice to tech pro — start learning today.