我的网格视图
<div style="margin-left: 280px">
<asp:GridView ID="exportGrdVw" runat="server" BackColor="White"
AllowPaging="True" PageSize="3"
OnPageIndexChanging="exportGrdVw_PageIndexChanging"
onpageindexchanged="exportGrdVw_PageIndexChanged">
</asp:GridView>
</div>
我的代码
SqlConnection con = new SqlConnection("server=acer-Pc\\Sql;database=MYDB;trusted_connection=yes");
//DataSet ds = new DataSet();
DataTable table = new DataTable();
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
SqlDataAdapter da = new SqlDataAdapter("select customername,contactno,address from employee ", con);
da.Fill(table);
BindEmployee();
}
}
public void BindEmployee()
{
exportGrdVw.DataSource = table;
exportGrdVw.DataBind();
}
protected void exportGrdVw_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
exportGrdVw.PageIndex = e.NewPageIndex;
BindEmployee();
}
问题是 gridview 正在显示,但是当我单击第 2 页时。第 2 页数据未显示(空白)。请帮我解决这个问题。查看代码是否正确