protected void GridView1_Load(object sender, EventArgs e) { int qw = GridView1.PageCount; if ( qw <= 0 ) { Response.Redirect("~/error.aspx"); } }