开发者

gridview paging problem

开发者 https://www.devze.com 2022-12-11 09:57 出处:网络
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 th

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消