Hi, can anyone help me with paging on a gridview please?

<asp:GridView ID="GridView1" CssClass="gridStyle" runat="server" 
                            AutoGenerateColumns="false" CaptionAlign="Bottom"
                        GridLines="Horizontal" onselectedindexchanged="GridView1_SelectedIndexChanged" OnRowEditing="GridView1_RowEditing"
                        ShowFooter="False" AlternatingRowStyle-BackColor="White" 
                            onrowcreated="GridView1_RowCreated" RowStyle-HorizontalAlign="Center" 
                            AllowPaging="True" onpageindexchanging="GridView1_PageIndexChanging" 
                            PageSize="5">
                        <RowStyle BackColor="#DEDFDE" ForeColor="Black" />
                        <Columns>
                            <asp:CommandField ShowEditButton="True" ButtonType="Button" ItemStyle-Width="40px" ControlStyle-CssClass="button" ControlStyle-Width="43px" ItemStyle-HorizontalAlign="Center" />
                            <asp:CommandField ShowSelectButton="True" ButtonType="Button" ItemStyle-Width="40px" ControlStyle-CssClass="button" ControlStyle-Width="43px" ItemStyle-HorizontalAlign="Center" />
                            <asp:BoundField DataField="ID" ItemStyle-Width="30px" HeaderText="ID" SortExpression="ID" ItemStyle-HorizontalAlign="Center" />
                            <asp:BoundField DataField="Date Created" ItemStyle-Width="70px" HeaderText="DATE CREATED" ItemStyle-HorizontalAlign="Center" />
                            <asp:BoundField DataField="User" ItemStyle-Width="90px" HeaderText="USER" ItemStyle-HorizontalAlign="Center" />
                            <asp:BoundField DataField="Incident Type" ItemStyle-Width="80px" HeaderText="INCIDENT TYPE" ItemStyle-HorizontalAlign="Center" />
                            <asp:BoundField DataField="Expiry Date" ItemStyle-Width="70px" HeaderText="EXPIRY DATE" ItemStyle-HorizontalAlign="Center" />
                            <asp:BoundField DataField="Status" ItemStyle-Width="80px" HeaderText="STATUS" ItemStyle-HorizontalAlign="Center" />
                            <asp:BoundField DataField="Direction" ItemStyle-Width="80px" HeaderText="DIRECTION" ItemStyle-HorizontalAlign="Center" />
                            <asp:BoundField DataField="Pos Dupl" ItemStyle-Width="80px" HeaderText="WARNING" ItemStyle-HorizontalAlign="Center" />
                        </Columns>
                        <FooterStyle BackColor="#0B6138" ForeColor="#FFFFFF" />
                        <PagerStyle BackColor="#C6C3C6" ForeColor="Black" HorizontalAlign="Center" />
                        <SelectedRowStyle BackColor="red" Font-Bold="True" ForeColor="White" HorizontalAlign="Center" />
                        <HeaderStyle CssClass="DataGridFixedHeader" HorizontalAlign="Left" />
                        </asp:GridView>

So i do get a grid with page numbers at the bottom, but when i click on the next page, the same data is drawn to the page.

protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            if (ds != null)
            {
                GridView1.DataKeyNames = new string[] { "ID" };
                GridView1.PageIndex = e.NewPageIndex;
                GridView1.DataSource = ds;
               // GridView1.DataBind();

                //GridView1.DataBind();
            }

Is thre a reason you have the part where you rebind the GridView commented out?

Yes, the error tha I receive is:

The IListSource does not contain any data sources.

But I dont know where or how to fill it, I inherited this project, and im not even an ASP.net guru...The rest is fairly easy, I fixed a lot of things, but this part is...sigh.

Where is the variable 'ds' gettings it's value from? How is 'ds' defined on the page?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.