Here when you click your next page., server is post pack..
so dt (datatable or dataset) should be empty.,
that is the problem., so you try to keep dt value as viewstate like
when you getting data from database then you assign like.,
GridView2.DataSource = dt;
then now you add page index changing code like this..
protected void GridView2_PageIndexChanging(object sender, GridViewPageEventArgs e)
GridView2.PageIndex = e.NewPageIndex;
GridView2.DataSource = viewstate("dt_data");
now you check page index is working fine.,
I hope this information is helpful to you.,
Thanks and regards