// Sanjay Gupta (gsanjay@novell.com)
//
// (C) 2003 Ben Maurer
-// (C) 2004 Novell, Inc. (http://www.novell.com)
+// (C) 2004-2010 Novell, Inc. (http://www.novell.com)
//
//
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-#if NET_2_0
using System.Collections;
using System.Collections.Specialized;
using System.Text;
namespace System.Web.UI {
public abstract class DataSourceView
{
- IDataSource dataSourceOwner;
+ //IDataSource dataSourceOwner;
string viewName = String.Empty;
protected DataSourceView (IDataSource owner, string viewName)
{
- this.dataSourceOwner = owner;
+ if (owner == null)
+ throw new ArgumentNullException ("owner");
+
+ //this.dataSourceOwner = owner;
this.viewName = viewName;
+ owner.DataSourceChanged += new EventHandler (OnDataSourceChanged);
+ }
+
+ void OnDataSourceChanged (object sender, EventArgs e) {
+ OnDataSourceViewChanged (EventArgs.Empty);
}
public virtual void Delete (IDictionary keys, IDictionary values,
if (callBack == null)
throw new ArgumentNullException ("callBack");
- int rowAffected = 0;
- Exception passOn = null;
+ int rowAffected;
try {
rowAffected = ExecuteDelete (keys, values);
- } catch (Exception e) {
- passOn = e;
}
-
- if (!callBack (rowAffected, passOn) && passOn != null)
- throw passOn;
+ catch (Exception e) {
+ if (!callBack (0, e))
+ throw;
+ return;
+ }
+ callBack (rowAffected, null);
}
protected virtual int ExecuteDelete(IDictionary keys, IDictionary values)
if (callBack == null)
throw new ArgumentNullException("callBack");
- int rowAffected = 0;
- Exception passOn = null;
+ int rowAffected;
try {
rowAffected = ExecuteInsert (values);
} catch (Exception e) {
- passOn = e;
+ if (!callBack (0, e))
+ throw;
+ return;
}
- if (!callBack (rowAffected, passOn) && passOn != null)
- throw passOn;
+ callBack (rowAffected, null);
}
protected virtual void OnDataSourceViewChanged (EventArgs eventArgs)
if (callBack == null)
throw new ArgumentNullException ("callBack");
- int rowAffected = 0;
- Exception passOn = null;
+ int rowAffected;
try {
rowAffected = ExecuteUpdate (keys, values, oldValues);
} catch (Exception e) {
- passOn = e;
+ if (!callBack (0, e))
+ throw;
+ return;
}
- if (!callBack (rowAffected, passOn) && passOn != null)
- throw passOn;
+ callBack (rowAffected, null);
}
public virtual bool CanDelete { get { return false; } }
return eventsList != null;
}
- public virtual string Name {
+ public string Name {
get { return viewName; }
}
}
}
-#endif