public DoGetData ( ) : System.Web.UI.DataSourceView | ||
return | System.Web.UI.DataSourceView |
public void GridView_CreateDataSourceSelectArguments () { DataSourceView view; Page p = new Page (); PokerGridView g = new PokerGridView (); g.Sorting += new GridViewSortEventHandler (g_Sorting); p.Controls.Add (g); ObjectDataSource data = new ObjectDataSource (); data.TypeName = typeof (DataSourceObject).AssemblyQualifiedName; data.SelectMethod = "GetList"; data.SortParameterName = "sortExpression"; DataSourceSelectArguments arg; p.Controls.Add (data); g.DataSource = data; g.DataBind (); arg = g.DoCreateDataSourceSelectArguments (); Assert.IsTrue (arg.Equals (DataSourceSelectArguments.Empty), "Default"); g.AllowPaging = true; g.PageIndex = 2; g.PageSize = 3; arg = g.DoCreateDataSourceSelectArguments (); view = g.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 = g.DoCreateDataSourceSelectArguments (); view = g.DoGetData (); Assert.IsTrue (view.CanPage); Assert.IsFalse (view.CanRetrieveTotalRowCount); Assert.IsTrue (arg.Equals (new DataSourceSelectArguments (6, -1)), "AllowPaging = true, CanPage = true, CanRetrieveTotalRowCount = false"); g.AllowPaging = false; arg = g.DoCreateDataSourceSelectArguments (); Assert.IsTrue (arg.Equals (DataSourceSelectArguments.Empty), "AllowPaging = false, CanPage = true, CanRetrieveTotalRowCount = false"); // make DataSourceView.CanRetrieveTotalRowCount = true data.SelectCountMethod = "GetCount"; arg = g.DoCreateDataSourceSelectArguments (); Assert.IsTrue (arg.Equals (DataSourceSelectArguments.Empty), "AllowPaging = false, CanPage = true, CanRetrieveTotalRowCount = true"); g.AllowPaging = true; arg = g.DoCreateDataSourceSelectArguments (); DataSourceSelectArguments arg1 = new DataSourceSelectArguments (6, 3); arg1.RetrieveTotalRowCount = true; view = g.DoGetData (); Assert.IsTrue (view.CanPage); Assert.IsTrue (view.CanRetrieveTotalRowCount); Assert.IsTrue (arg.Equals (arg1), "AllowPaging = true, CanPage = true, CanRetrieveTotalRowCount = true"); 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); Assert.AreEqual (String.Empty, g.SortExpression, "SortExpression, Bound by DataSource"); Assert.AreEqual (SortDirection.Ascending, g.SortDirection, "SortDirection, Bound by DataSource"); Assert.IsTrue (arg.Equals (DataSourceSelectArguments.Empty), "AllowSorting = true, Bound by DataSource"); }
public void GridView_Sort_and_DataSourceSelectArguments () { DataSourceView view; DataSourceSelectArguments arg; Page p = new Page (); PokerGridView g = new PokerGridView (); g.Columns.Add (new BoundField ()); g.AllowSorting = true; p.Controls.Add (g); ObjectDataSource data = new ObjectDataSource (); data.TypeName = typeof (DataSourceObject).AssemblyQualifiedName; data.SelectMethod = "GetList"; data.SortParameterName = "sortExpression"; data.ID = "Data"; 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); Assert.AreEqual ("sort", g.SortExpression, "SortExpression, Bound by DataSourceID"); Assert.AreEqual (SortDirection.Descending, g.SortDirection, "SortDirection, Bound by DataSourceID"); Assert.AreEqual ("sort DESC", arg.SortExpression, "AllowSorting = true, Bound by DataSourceID"); g.AllowSorting = false; arg = g.DoCreateDataSourceSelectArguments (); Assert.AreEqual ("sort DESC", arg.SortExpression, "AllowSorting = false, Bound by DataSourceID"); }