Przeglądaj źródła

2005-09-29 Gonzalo Paniagua Javier <[email protected]>

	* PagedDataSource.cs: fix IsLastPage. All tests pass.
	* DataGrid.cs: InitializePager always add a cell and it's brand new. No
	need to keep the old one in a field. Now all tests pass here too.


svn path=/trunk/mcs/; revision=50983
Gonzalo Paniagua Javier 20 lat temu
rodzic
commit
6ea0412c5b

+ 6 - 0
mcs/class/System.Web/System.Web.UI.WebControls/ChangeLog

@@ -1,3 +1,9 @@
+2005-09-29 Gonzalo Paniagua Javier <[email protected]>
+
+	* PagedDataSource.cs: fix IsLastPage. All tests pass.
+	* DataGrid.cs: InitializePager always add a cell and it's brand new. No
+	need to keep the old one in a field. Now all tests pass here too.
+
 2005-09-28 Gonzalo Paniagua Javier <[email protected]>
 
 	* PagedDataSource.cs: don't use the properties when they just return a

+ 7 - 14
mcs/class/System.Web/System.Web.UI.WebControls/DataGrid.cs

@@ -86,7 +86,6 @@ namespace System.Web.UI.WebControls {
 
 		private Table render_table;
 		private DataGridColumn [] render_columns;
-		private TableCell pager_cell;
 		private PagedDataSource paged_data_source;
 		private IEnumerator data_enumerator;
 		
@@ -671,17 +670,13 @@ namespace System.Web.UI.WebControls {
 			}
 		}
 
-		protected virtual void InitializePager (DataGridItem item, int columnSpan,
-				PagedDataSource pagedDataSource)
+		protected virtual void InitializePager (DataGridItem item, int columnSpan, PagedDataSource pagedDataSource)
 		{
-			if (pager_cell == null) {
-				if (PagerStyle.Mode == PagerMode.NextPrev)
-					pager_cell = InitializeNextPrevPager (item,
-							columnSpan, pagedDataSource);
-				else
-					pager_cell = InitializeNumericPager (item,
-							columnSpan, pagedDataSource);
-			}
+			TableCell pager_cell;
+			if (PagerStyle.Mode == PagerMode.NextPrev)
+				pager_cell = InitializeNextPrevPager (item, columnSpan, pagedDataSource);
+			else
+				pager_cell = InitializeNumericPager (item, columnSpan, pagedDataSource);
 
 			item.Controls.Add (pager_cell);
 		}
@@ -743,8 +738,7 @@ namespace System.Web.UI.WebControls {
 			return res;
 		}
 
-		private TableCell InitializeNextPrevPager (DataGridItem item, int columnSpan,
-				PagedDataSource paged)
+		private TableCell InitializeNextPrevPager (DataGridItem item, int columnSpan, PagedDataSource paged)
 		{
 			TableCell res = new TableCell ();
 			res.ColumnSpan = columnSpan;
@@ -915,7 +909,6 @@ namespace System.Web.UI.WebControls {
 
 			if (useDataSource)
 				ViewState ["Items"] = index;
-			pager_cell = null;
 		}
 
 		void ApplyColumnStyle (TableCellCollection cells, ListItemType type)

+ 2 - 10
mcs/class/System.Web/System.Web.UI.WebControls/PagedDataSource.cs

@@ -42,10 +42,6 @@ namespace System.Web.UI.WebControls {
 		public PagedDataSource ()
 		{
 			page_size = 10;
-			allow_paging = false;
-			current_page_index = 0;
-			allow_custom_paging = false;
-			virtual_count = 0;
 		}
 
 		public bool AllowCustomPaging {
@@ -122,14 +118,10 @@ namespace System.Web.UI.WebControls {
 
 		public bool IsLastPage {
 			get {
-				if (!allow_paging)
+				if (!allow_paging || page_size == 0)
 					return true;
 
-				int pcount = PageCount;
-				if (pcount == 0)
-					return false;
-
-				return (current_page_index == pcount - 1);
+				return  (current_page_index == (PageCount - 1));
 			}
 		}