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" AutoGenerat开发者_如何学运维eColumns="False" CssClass="Grid" HeaderStyle-BackColor="#7E7E7C" Width="700px" AllowPaging="True" AllowSorting="True" OnPageIndexChanging="GridView_attendancereports_PageIndexChanging" PageSize="5" >
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();
}
try rebinding to your datasource.
精彩评论