This is how I fixed the problem, but still don't know why grid.PageIndex
contained random values in the code above.
private void SetGridDataSource()
{
grid.DataSource = GetListOfSomeType();
grid.DataBind();
grid.PageIndexChanged += new EventHandler(grid_PageIndexChanged);
}
void grid_PageIndexChanged(object sender, EventArgs e)
{
grid.Settings.ShowFooter = (grid.PageIndex == grid.PageCount - 1);
}