C# 未处理NotSupportedException(gridview C)
我试图在gridview中显示我的数据。 它工作正常,直到。 我想进行分页(每页20个数据),这会导致错误NotSupportedException未处理 我如何解决这个问题 这是我的密码。 我还将分页设置为trueC# 未处理NotSupportedException(gridview C),c#,gridview,paging,C#,Gridview,Paging,我试图在gridview中显示我的数据。 它工作正常,直到。 我想进行分页(每页20个数据),这会导致错误NotSupportedException未处理 我如何解决这个问题 这是我的密码。 我还将分页设置为true public void bindGV() { string strCon = Database.GetConStr(); SqlConnection sqlCon = new SqlConnection(strCon); Sq
public void bindGV()
{
string strCon = Database.GetConStr();
SqlConnection sqlCon = new SqlConnection(strCon);
SqlCommand sqlCommand = new SqlCommand("select * from Account", sqlCon);
sqlCon.Open();
SqlDataReader reader = sqlCommand.ExecuteReader();
StaffGV.DataSource = reader;
StaffGV.DataBind();
}
protected void GV_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
GV.PageIndex = e.NewPageIndex;
bindGV();
}
错误来自GV_PageIndex。请从
PageIndexchange
事件中删除代码并查看发生了什么
再次阅读您的代码&这意味着,每次单击下一页时,您都希望从数据库获取数据并将其绑定到datagrid。这必须而不是完成
在datagrid中处理分页不需要做任何显式的操作,只需要设置一些属性。阅读一些关于如何在datagrid中处理分页的介绍教程。编辑您自己的问题并发布异常的stacktrace。