这是我的代码:当我更改寻呼机的索引时,我得到了正确的数据,但寻呼机页脚消失了:
<asp:GridView ID="GridView1" runat="server" PageSize="4" AllowPaging="true" AllowSorting="true" AutoGenerateColumns="false" OnRowEditing="GridView1_RowEditing" DataKeyNames="id" OnRowCancelingEdit="GridView1_RowCancelingEdit" AlternatingRowStyle-CssClass="eventRowStyle" OnPageIndexChanging="GridView1_PageIndexChanging" OnPageIndexChanged="GridView1_PageIndexChanged">
代码隐藏:
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
GridViewDBEntities model = new GridViewDBEntities();
var query = from p in model.userTbls select p;
GridView1.DataSource = query;
GridView1.DataBind();
}
}
protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
GridViewDBEntities model = new GridViewDBEntities();
var query = (from p in model.userTbls orderby p.id ascending select p).Skip((e.NewPageIndex) * GridView1.PageSize).Take(GridView1.PageSize);
GridView1.PageIndex = e.NewPageIndex;
GridView1.DataSource = query;
GridView1.DataBind();
}