我在 GridView 中有很多 ServerName 列表,所以我决定添加分页。数据在第 1 页但在第 2 页显示列表结果,其余部分不显示任何内容。我已经OnPageIndexChanging="GridViewServer_PageIndexChanging"
在 GridViewServer 属性中。请帮忙!这是后面的c#代码,
protected void GridViewServer_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
GridViewServer.PageIndex = e.NewPageIndex;
GridViewServer.DataBind();
}
一个GridView绑定功能代码,
public void BindGridView()
{
SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["Database_Shared_NotebookConnectionString"].ConnectionString);
conn.Open();
string sqlquery = ("SELECT * FROM tblServer");
SqlCommand command = new SqlCommand(sqlquery, conn);
SqlDataAdapter adp = new SqlDataAdapter(command);
DataSet ds = new DataSet();
adp.Fill(ds);
GridViewServer.DataSource = ds.Tables[0];
GridViewServer.DataBind();
}