Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

2006-10-12 Igor Zelmanovich <igorz@mainsoft.com>

	* GridView.cs: fixed: Sorting feature.
	When sorting EditIndex and PageIndex are reseted


svn path=/trunk/mcs/; revision=66597
  • Loading branch information...
commit 4df8f73c78675213769d525d522541c21a16f259 1 parent d0ccf3d
Igor Zelmanovich authored
View
5 mcs/class/System.Web/System.Web.UI.WebControls/ChangeLog
@@ -1,6 +1,11 @@
2006-10-12 Igor Zelmanovich <igorz@mainsoft.com>
* GridView.cs: fixed: Sorting feature.
+ When sorting EditIndex and PageIndex are reseted
+
+2006-10-12 Igor Zelmanovich <igorz@mainsoft.com>
+
+ * GridView.cs: fixed: Sorting feature.
CreateDataSourceSelectArguments considers SortExpression and SortDirection.
(corresponding test does not work because bug in ObjectDataSourceView)
View
21 mcs/class/System.Web/System.Web.UI.WebControls/GridView.cs
@@ -929,13 +929,13 @@ public virtual string[] DataKeyNames
[DefaultValueAttribute (SortDirection.Ascending)]
[DesignerSerializationVisibilityAttribute (DesignerSerializationVisibility.Hidden)]
public virtual SortDirection SortDirection {
- get { return IsBoundUsingDataSourceID ? sortDirection : SortDirection.Ascending; }
+ get { return sortDirection; }
}
[BrowsableAttribute (false)]
[DesignerSerializationVisibilityAttribute (DesignerSerializationVisibility.Hidden)]
public virtual string SortExpression {
- get { return IsBoundUsingDataSourceID ? sortExpression : String.Empty; }
+ get { return sortExpression; }
}
[DesignerSerializationVisibilityAttribute (DesignerSerializationVisibility.Hidden)]
@@ -1557,15 +1557,10 @@ void ProcessEvent (string eventName, string param)
void Sort (string newSortExpression)
{
- SortDirection newDirection;
- if (sortExpression == newSortExpression) {
- if (sortDirection == SortDirection.Ascending)
- newDirection = SortDirection.Descending;
- else
- newDirection = SortDirection.Ascending;
- } else
- newDirection = sortDirection;
-
+ SortDirection newDirection = SortDirection.Ascending;
+ if (sortExpression == newSortExpression && sortDirection == SortDirection.Ascending)
+ newDirection = SortDirection.Descending;
+
Sort (newSortExpression, newDirection);
}
@@ -1575,9 +1570,13 @@ public virtual void Sort (string newSortExpression, SortDirection newSortDirecti
OnSorting (args);
if (args.Cancel) return;
+ if (IsBoundUsingDataSourceID) {
+ EditIndex = -1;
+ PageIndex = 0;
sortExpression = args.SortExpression;
sortDirection = args.SortDirection;
RequireBinding ();
+ }
OnSorted (EventArgs.Empty);
}
View
4 mcs/class/System.Web/Test/System.Web.UI.WebControls/ChangeLog
@@ -1,5 +1,9 @@
2006-10-12 Igor Zelmanovich <igorz@mainsoft.com>
+ * GridViewTest.cs: added tests
+
+2006-10-12 Igor Zelmanovich <igorz@mainsoft.com>
+
* GridViewTest.cs: added test
2006-10-11 Igor Zelmanovich <igorz@mainsoft.com>
View
11 mcs/class/System.Web/Test/System.Web.UI.WebControls/GridViewTest.cs
@@ -525,10 +525,15 @@ public void GridView_DefaultProtectedProperties ()
p.Controls.Add (data);
g.DataSourceID = "Data";
+ g.EditIndex = 2;
+ g.PageIndex = 1;
g.DataBind ();
g.Sort ("sort", SortDirection.Descending);
+ Assert.AreEqual (-1, g.EditIndex, "EditIndex after Sort, Bound by DataSourceID");
+ Assert.AreEqual (0, g.PageIndex, "PageIndex after Sort, Bound by DataSourceID");
+
arg = g.DoCreateDataSourceSelectArguments();
view = g.DoGetData ();
Assert.IsTrue (view.CanSort);
@@ -608,7 +613,13 @@ public void GridView_DefaultProtectedProperties ()
g.AllowPaging = false;
g.AllowSorting = true;
+ g.EditIndex = 2;
+ g.PageIndex = 1;
g.Sort ("sort", SortDirection.Descending);
+
+ Assert.AreEqual (2, g.EditIndex, "EditIndex after Sort, Bound by DataSource");
+ Assert.AreEqual (1, g.PageIndex, "PageIndex after Sort, Bound by DataSource");
+
arg = g.DoCreateDataSourceSelectArguments ();
view = g.DoGetData ();
Assert.IsTrue (view.CanSort);
Please sign in to comment.
Something went wrong with that request. Please try again.