Author: igorz
Date: 2006-09-25 07:48:43 -0400 (Mon, 25 Sep 2006)
New Revision: 65880
Modified:
trunk/mcs/class/System.Web/System.Web.UI.WebControls/ChangeLog
trunk/mcs/class/System.Web/System.Web.UI.WebControls/DataBoundControl.cs
trunk/mcs/class/System.Web/Test/System.Web.UI.WebControls/ChangeLog
trunk/mcs/class/System.Web/Test/System.Web.UI.WebControls/DataBoundControlTest.cs
Log:
2006-09-25 Igor Zelmanovich <[EMAIL PROTECTED]>
* DataBoundControl.cs: fixed: DataBind flow
GetData return "empty" DataSourceView when no DataSource and
DataSourceID
was assigned to cause PerformDataBinding be called.
Modified: trunk/mcs/class/System.Web/System.Web.UI.WebControls/ChangeLog
===================================================================
--- trunk/mcs/class/System.Web/System.Web.UI.WebControls/ChangeLog
2006-09-25 11:26:45 UTC (rev 65879)
+++ trunk/mcs/class/System.Web/System.Web.UI.WebControls/ChangeLog
2006-09-25 11:48:43 UTC (rev 65880)
@@ -1,3 +1,9 @@
+2006-09-25 Igor Zelmanovich <[EMAIL PROTECTED]>
+
+ * DataBoundControl.cs: fixed: DataBind flow
+ GetData return "empty" DataSourceView when no DataSource and
DataSourceID
+ was assigned to cause PerformDataBinding be called.
+
2006-09-24 Gonzalo Paniagua Javier <[EMAIL PROTECTED]>
* DataList.cs: use ExtractTemplateRows to determine if the style is
Modified:
trunk/mcs/class/System.Web/System.Web.UI.WebControls/DataBoundControl.cs
===================================================================
--- trunk/mcs/class/System.Web/System.Web.UI.WebControls/DataBoundControl.cs
2006-09-25 11:26:45 UTC (rev 65879)
+++ trunk/mcs/class/System.Web/System.Web.UI.WebControls/DataBoundControl.cs
2006-09-25 11:48:43 UTC (rev 65880)
@@ -84,15 +84,11 @@
return (IDataSource) ctrl;
}
- if (DataSource == null) return null;
-
IDataSource ds = DataSource as IDataSource;
if (ds != null) return ds;
- IEnumerable ie = DataSourceHelper.GetResolvedDataSource
(DataSource, DataMember);
- if (ie != null) return new CollectionDataSource (ie);
-
- throw new HttpException (string.Format ("Unexpected
data source type: {0}", DataSource.GetType()));
+ IEnumerable ie = DataSourceResolver.ResolveDataSource
(DataSource, DataMember);
+ return new CollectionDataSource (ie);
}
protected virtual DataSourceView GetData ()
@@ -192,17 +188,23 @@
if (!IsBoundUsingDataSourceID)
OnDataBinding (EventArgs.Empty);
- DataSourceView view = GetData ();
- if (view != null) {
- view.Select (SelectArguments, new
DataSourceViewSelectCallback (OnSelect));
- MarkAsDataBound ();
- }
+ GetData ().Select (SelectArguments, new
DataSourceViewSelectCallback (OnSelect));
+ MarkAsDataBound ();
+
+ // Raise the DataBound event.
+ OnDataBound (EventArgs.Empty);
}
void OnSelect (IEnumerable data)
{
+ // Call OnDataBinding only if it has not already been
+ // called in the PerformSelect method.
+ if (IsBoundUsingDataSourceID) {
+ OnDataBinding (EventArgs.Empty);
+ }
+ // The PerformDataBinding method binds the data in the
+ // retrievedData collection to elements of the
data-bound control.
PerformDataBinding (data);
- OnDataBound (EventArgs.Empty);
}
protected virtual DataSourceSelectArguments
CreateDataSourceSelectArguments ()
@@ -236,3 +238,4 @@
}
#endif
+
Modified: trunk/mcs/class/System.Web/Test/System.Web.UI.WebControls/ChangeLog
===================================================================
--- trunk/mcs/class/System.Web/Test/System.Web.UI.WebControls/ChangeLog
2006-09-25 11:26:45 UTC (rev 65879)
+++ trunk/mcs/class/System.Web/Test/System.Web.UI.WebControls/ChangeLog
2006-09-25 11:48:43 UTC (rev 65880)
@@ -1,3 +1,7 @@
+2006-09-25 Igor Zelmanovich <[EMAIL PROTECTED]>
+
+ * DataBoundControlTest.cs: New test was added
+
2006-09-19 Yoni Klain <[EMAIL PROTECTED]>
* CrossPagePostingTest.cs: New test was added
Modified:
trunk/mcs/class/System.Web/Test/System.Web.UI.WebControls/DataBoundControlTest.cs
===================================================================
---
trunk/mcs/class/System.Web/Test/System.Web.UI.WebControls/DataBoundControlTest.cs
2006-09-25 11:26:45 UTC (rev 65879)
+++
trunk/mcs/class/System.Web/Test/System.Web.UI.WebControls/DataBoundControlTest.cs
2006-09-25 11:48:43 UTC (rev 65880)
@@ -36,6 +36,10 @@
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
+using System.Text;
+using System.Collections;
+using System.Data;
+using MonoTests.SystemWeb.Framework;
namespace MonoTests.System.Web.UI.WebControls
{
@@ -47,8 +51,107 @@
Console.WriteLine ("PerformSelect\n{0}",
Environment.StackTrace);
}
}
+
+ class MyDataBoundControl : DataBoundControl
+ {
+ private StringBuilder dataBindTrace = new StringBuilder
();
+ public string DataBindTrace {
+ get { return dataBindTrace.ToString (); }
+ }
+
+ public override void DataBind () {
+ dataBindTrace = new StringBuilder ();
+ dataBindTrace.Append ("[Start DataBind]");
+ base.DataBind ();
+ dataBindTrace.Append ("[End DataBind]");
+ }
+
+ protected override void PerformSelect () {
+ dataBindTrace.Append ("[Start PerformSelect]");
+ base.PerformSelect ();
+ dataBindTrace.Append ("[End PerformSelect]");
+ }
+
+ protected override void PerformDataBinding (IEnumerable
data) {
+ dataBindTrace.Append ("[Start
PerformDataBinding]");
+ base.PerformDataBinding (data);
+ dataBindTrace.Append ("[End
PerformDataBinding]");
+ }
+
+ protected override void OnDataBinding (EventArgs e) {
+ dataBindTrace.Append ("[Start OnDataBinding]");
+ base.OnDataBinding (e);
+ dataBindTrace.Append ("[End OnDataBinding]");
+ }
+
+ protected override void OnDataBound (EventArgs e) {
+ dataBindTrace.Append ("[Start OnDataBound]");
+ base.OnDataBound (e);
+ dataBindTrace.Append ("[End OnDataBound]");
+ }
+
+ protected override DataSourceView GetData () {
+ dataBindTrace.Append ("[Start GetData]");
+ DataSourceView d = base.GetData ();
+ dataBindTrace.Append ("[End GetData]");
+ return d;
+ }
+
+ public DataSourceView DoGetData () {
+ return GetData ();
+ }
+
+ public IDataSource DoGetDataSource () {
+ return GetDataSource ();
+ }
+
+ public void DoEnsureDataBound () {
+ EnsureDataBound();
+ }
+ }
+
+ [Test]
+ public void DataBoundControl_GetData () {
+ Page p = new Page ();
+ MyDataBoundControl dc = new MyDataBoundControl ();
+ p.Controls.Add (dc);
+
+ DataSourceView data = dc.DoGetData ();
+ Assert.IsNotNull (data, "GetData");
+
+ IDataSource dataSource = dc.DoGetDataSource ();
+ Assert.IsNotNull (dataSource, "GetDataSource");
+ }
+
+ [Test]
+ public void DataBoundControl_DataBindFlow () {
+ Page p = new Page ();
+ MyDataBoundControl dc = new MyDataBoundControl ();
+ p.Controls.Add (dc);
+ dc.DataBind ();
+ string expected = "[Start DataBind][Start
PerformSelect][Start OnDataBinding][End OnDataBinding][Start GetData][End
GetData][Start PerformDataBinding][End PerformDataBinding][Start
OnDataBound][End OnDataBound][End PerformSelect][End DataBind]";
+ Assert.AreEqual (expected, dc.DataBindTrace,
"DataBindFlow");
+ }
[Test]
+ [Category ("NunitWeb")]
+ public void DataBoundControl_DataBindFlow2 () {
+ new WebTest (PageInvoker.CreateOnLoad
(DataBoundControl_DataBindFlow2_Load)).Run ();
+ }
+
+ public static void DataBoundControl_DataBindFlow2_Load(Page p){
+ MyDataBoundControl dc = new MyDataBoundControl ();
+ p.Controls.Add (dc);
+ dc.DataSourceID = "ObjectDataSource1";
+ ObjectDataSource ods = new ObjectDataSource
(typeof(Control).FullName, "ToString");
+ ods.ID = "ObjectDataSource1";
+ p.Controls.Add (ods);
+ dc.DataBind ();
+ string expected = "[Start DataBind][Start
PerformSelect][Start GetData][End GetData][Start OnDataBinding][End
OnDataBinding][Start PerformDataBinding][End PerformDataBinding][Start
OnDataBound][End OnDataBound][End PerformSelect][End DataBind]";
+ Assert.AreEqual (expected, dc.DataBindTrace,
"DataBindFlow");
+ }
+
+ [Test]
public void Defaults ()
{
Poker p = new Poker ();
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches