Author: igorz
Date: 2006-10-17 12:50:08 -0400 (Tue, 17 Oct 2006)
New Revision: 66755

Modified:
   trunk/mcs/class/System.Web/System.Web.UI.WebControls/ChangeLog
   trunk/mcs/class/System.Web/System.Web.UI.WebControls/FormView.cs
   trunk/mcs/class/System.Web/Test/System.Web.UI.WebControls/ChangeLog
   trunk/mcs/class/System.Web/Test/System.Web.UI.WebControls/FormViewTest.cs
Log:
2006-10-17 Igor Zelmanovich <[EMAIL PROTECTED]>

        * FormView.cs: fixed: CreateDataSourceSelectArguments method.
        (corresponding test does not work because bug in ObjectDataSourceView)



Modified: trunk/mcs/class/System.Web/System.Web.UI.WebControls/ChangeLog
===================================================================
--- trunk/mcs/class/System.Web/System.Web.UI.WebControls/ChangeLog      
2006-10-17 16:44:51 UTC (rev 66754)
+++ trunk/mcs/class/System.Web/System.Web.UI.WebControls/ChangeLog      
2006-10-17 16:50:08 UTC (rev 66755)
@@ -1,5 +1,10 @@
 2006-10-17 Igor Zelmanovich <[EMAIL PROTECTED]>
 
+       * FormView.cs: fixed: CreateDataSourceSelectArguments method.
+       (corresponding test does not work because bug in ObjectDataSourceView)
+
+2006-10-17 Igor Zelmanovich <[EMAIL PROTECTED]>
+
        * DataBoundControl.cs: fixed: DataBind calls
        CreateDataSourceSelectArguments() and stores result in  SelectArguments
 

Modified: trunk/mcs/class/System.Web/System.Web.UI.WebControls/FormView.cs
===================================================================
--- trunk/mcs/class/System.Web/System.Web.UI.WebControls/FormView.cs    
2006-10-17 16:44:51 UTC (rev 66754)
+++ trunk/mcs/class/System.Web/System.Web.UI.WebControls/FormView.cs    
2006-10-17 16:50:08 UTC (rev 66755)
@@ -781,7 +781,19 @@
                
                protected override DataSourceSelectArguments 
CreateDataSourceSelectArguments ()
                {
-                       return base.CreateDataSourceSelectArguments ();
+                       DataSourceSelectArguments arg = new 
DataSourceSelectArguments ();
+                       DataSourceView view = GetData ();
+                       if (AllowPaging && view.CanPage) {
+                               arg.StartRowIndex = PageIndex;
+                               if (view.CanRetrieveTotalRowCount) {
+                                       arg.RetrieveTotalRowCount = true;
+                                       arg.MaximumRows = 1;
+                               }
+                               else {
+                                       arg.MaximumRows = -1;
+                               }
+                       }
+                       return arg;
                }
                
                protected virtual FormViewRow CreateRow (int rowIndex, 
DataControlRowType rowType, DataControlRowState rowState)
@@ -1038,14 +1050,6 @@
                                PerformDataBinding (new object [] { null });
                                return;
                        }
-                       
-                       DataSourceView view = GetData ();
-                       if (AllowPaging && view.CanPage) {
-                               SelectArguments.StartRowIndex = PageIndex;
-                               SelectArguments.MaximumRows = 1;
-                               if (view.CanRetrieveTotalRowCount)
-                                       SelectArguments.RetrieveTotalRowCount = 
true;
-                       }
 
                        cachedKeyProperties = null;
                        base.DataBind ();

Modified: trunk/mcs/class/System.Web/Test/System.Web.UI.WebControls/ChangeLog
===================================================================
--- trunk/mcs/class/System.Web/Test/System.Web.UI.WebControls/ChangeLog 
2006-10-17 16:44:51 UTC (rev 66754)
+++ trunk/mcs/class/System.Web/Test/System.Web.UI.WebControls/ChangeLog 
2006-10-17 16:50:08 UTC (rev 66755)
@@ -1,5 +1,9 @@
 2006-10-17 Igor Zelmanovich <[EMAIL PROTECTED]>
 
+       * FormViewTest.cs: added tests
+                       
+2006-10-17 Igor Zelmanovich <[EMAIL PROTECTED]>
+
        * DataBoundControlTest.cs: added test
                        
 2006-10-17 Vladimir Krasnov <[EMAIL PROTECTED]>

Modified: 
trunk/mcs/class/System.Web/Test/System.Web.UI.WebControls/FormViewTest.cs
===================================================================
--- trunk/mcs/class/System.Web/Test/System.Web.UI.WebControls/FormViewTest.cs   
2006-10-17 16:44:51 UTC (rev 66754)
+++ trunk/mcs/class/System.Web/Test/System.Web.UI.WebControls/FormViewTest.cs   
2006-10-17 16:50:08 UTC (rev 66755)
@@ -54,6 +54,37 @@
 {
        [TestFixture]   
        public class FormViewTest {     
+
+               public class DataSourceObject
+               {
+                       public static List<string> GetList (string 
sortExpression, int startRowIndex, int maximumRows) {
+                               return GetList ();
+                       }
+
+                       public static List<string> GetList (int startRowIndex, 
int maximumRows) {
+                               return GetList ();
+                       }
+
+                       public static List<string> GetList (string 
sortExpression) {
+                               return GetList ();
+                       }
+
+                       public static List<string> GetList () {
+                               List<string> list = new List<string> ();
+                               list.Add ("Norway");
+                               list.Add ("Sweden");
+                               list.Add ("France");
+                               list.Add ("Italy");
+                               list.Add ("Israel");
+                               list.Add ("Russia");
+                               return list;
+                       }
+
+                       public static int GetCount () {
+                               return GetList ().Count;
+                       }
+               }
+               
                public class Poker : FormView {
                        public bool isInitializePager=false;
                        public bool ensureDataBound=false;
@@ -95,6 +126,11 @@
                                return CreateDataSourceSelectArguments ();
                        }
 
+                       public DataSourceView DoGetData ()
+                       {
+                               return GetData ();
+                       }
+
                        public FormViewRow DoCreateRow (int 
itemIndex,DataControlRowType rowType,DataControlRowState rowState)
                        {
                                return CreateRow( itemIndex, rowType,rowState); 
@@ -1675,6 +1711,65 @@
                        view.ChangeMode (FormViewMode.Edit);
                        Assert.AreEqual (FormViewMode.Edit, view.CurrentMode, 
"FormView_CurrentMode#2");
                }
+
+               [Test]
+               [Category ("NotWorking")]
+               public void FormView_CreateDataSourceSelectArguments2 () {
+                       DataSourceView view;
+                       Page p = new Page ();
+
+                       Poker dv = new Poker ();
+                       p.Controls.Add (dv);
+
+                       ObjectDataSource data = new ObjectDataSource ();
+                       data.TypeName = typeof 
(DataSourceObject).AssemblyQualifiedName;
+                       data.SelectMethod = "GetList";
+                       data.SortParameterName = "sortExpression";
+                       DataSourceSelectArguments arg;
+                       p.Controls.Add (data);
+
+                       dv.DataSource = data;
+                       dv.DataBind ();
+
+                       arg = dv.DoCreateDataSourceSelectArguments ();
+                       Assert.IsTrue (arg.Equals 
(DataSourceSelectArguments.Empty), "Default");
+
+                       dv.AllowPaging = true;
+                       dv.PageIndex = 2;
+                       arg = dv.DoCreateDataSourceSelectArguments ();
+                       view = dv.DoGetData ();
+                       Assert.IsFalse (view.CanPage);
+                       Assert.IsTrue (view.CanRetrieveTotalRowCount);
+                       Assert.IsTrue (arg.Equals 
(DataSourceSelectArguments.Empty), "AllowPaging = true, CanPage = false, 
CanRetrieveTotalRowCount = true");
+
+                       // make DataSourceView.CanPage = true
+                       data.EnablePaging = true;
+
+                       arg = dv.DoCreateDataSourceSelectArguments ();
+                       view = dv.DoGetData ();
+                       Assert.IsTrue (view.CanPage);
+                       Assert.IsFalse (view.CanRetrieveTotalRowCount);
+                       Assert.IsTrue (arg.Equals (new 
DataSourceSelectArguments (2, -1)), "AllowPaging = true, CanPage = true, 
CanRetrieveTotalRowCount = false");
+
+                       dv.AllowPaging = false;
+                       arg = dv.DoCreateDataSourceSelectArguments ();
+                       Assert.IsTrue (arg.Equals 
(DataSourceSelectArguments.Empty), "AllowPaging = false, CanPage = true, 
CanRetrieveTotalRowCount = false");
+
+                       // make DataSourceView.CanRetrieveTotalRowCount = true
+                       data.SelectCountMethod = "GetCount";
+
+                       arg = dv.DoCreateDataSourceSelectArguments ();
+                       Assert.IsTrue (arg.Equals 
(DataSourceSelectArguments.Empty), "AllowPaging = false, CanPage = true, 
CanRetrieveTotalRowCount = true");
+
+                       dv.AllowPaging = true;
+                       arg = dv.DoCreateDataSourceSelectArguments ();
+                       DataSourceSelectArguments arg1 = new 
DataSourceSelectArguments (2, 1);
+                       arg1.RetrieveTotalRowCount = true;
+                       view = dv.DoGetData ();
+                       Assert.IsTrue (view.CanPage);
+                       Assert.IsTrue (view.CanRetrieveTotalRowCount);
+                       Assert.IsTrue (arg.Equals (arg1), "AllowPaging = true, 
CanPage = true, CanRetrieveTotalRowCount = true");
+               }
        }
 
        public class TestMyData

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to