public int PageCount {
get {
if (dataSource == null)
return 0;
int dataSourceItemCount = DataSourceCount;
if (IsPagingEnabled && (dataSourceItemCount > 0)) {
int pageCountNum = dataSourceItemCount + pageSize - 1;
if (pageCountNum < 0) {
return 1; // integer overflow
}
return (int)(pageCountNum/pageSize);
}
else {
return 1;
}
}
}