I am trying to display my data in a gridview. It works fine, until . . . . . I want to do paging (20 data per page), it causes an error NotSupportedException was unhandled .
How do i solve this?
This is my code. I also have set paging to true.
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();
}
The error comes from the GV_PageIndex.