我使用gridview,其中当单击下一页时pagingsize为5,它返回空数据。但实际上它有12个datas.im,使用sql作为后端,asp.net c#和数据r在运行时计算并显示。 即时通讯使用此代码
<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" >
答案 0 :(得分:2)
你需要在页面索引更改事件中重新绑定,如
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();
}
答案 1 :(得分:1)
尝试重新绑定到您的数据源。