Anand
Anand

Reputation: 15

gridview paging problem

i m using an gridview in which pagingsize is 5 when the next page is clicked it returns empty data. but actually it has 12 datas.im using sql as back end and asp.net c# and the data r calculated at the run time and displayed. im using this code

<asp:GridView ID="GridView_attendancereports"  BorderWidth="1px" BorderColor="#DBDBDA" runat="server" AutoGenerateColumns="False" CssClass="Grid" HeaderStyle-BackColor="#7E7E7C" Width="700px" AllowPaging="True" AllowSorting="True" OnPageIndexChanging="GridView_attendancereports_PageIndexChanging" PageSize="5"  >

Upvotes: 0

Views: 1659

Answers (2)

Muhammad Akhtar
Muhammad Akhtar

Reputation: 52241

you need to rebind in page index changing event like

protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
    GridView1.PageIndex = e.NewPageIndex;
    DataTable dt = GetAllCity();// you need to get here again data from database or from some other sources as you have, to populate your gridview properly
    GridView1.DataSource = dt.DefaultView;
    GridView1.DataBind();
}

Upvotes: 2

adrianos
adrianos

Reputation: 1561

try rebinding to your datasource.

Upvotes: 1

Related Questions