Help with GridView Paging PLEASE
-
PROBLEM: No matter what I do, I can't seem to get GridView paging to work programatically. BACKGROUND: OK, I have a biztier referenced in my solution. The biztier has two methods, one returning a SqlDataReader from a StoredProc, and the other returning a DataTable created from the previous method. For sure I know I cannot get paging (or sorting) from the DataReader.. but I thought I could get it from a DataTable, or a DataView, since they implement IEnumerable. CODE: On first trip, the page calls ShowClicks() with the code below. If I click a Pager button, the page posts back with the correct NewPageIndex, but I get blank results.. this happens if I call DataBind() or not. Even assigning the DataTable directly (without caching it) or creating a DataView, I get the same behaviour. Anyone have an idea what gives? :(
private void ShowClicks()
{
PAYCAdmin AdminBL = new PAYCAdmin();
DataTable dt = null;
dt = AdminBL.GetAdminDailyClickStatsDT();
// Insert DataTable into Cache object
Cache.Insert("dtCache", dt);
DataTable dtCache = (DataTable)Cache.Get("dtCache");
gvClicks.DataSource = dtCache;
//gvClicks.EnableSortingAndPagingCallbacks = true;
gvClicks.PageSize = 15;
gvClicks.DataBind();
}protected void gvClicks\_PageIndexChanging(object sender, GridViewPageEventArgs e) { gvClicks.PageIndex = e.NewPageIndex; gvClicks.DataBind(); }
Practice sesquipedalianism! ;)