2004-04-22 Martin Baulig <martin@ximian.com>
[mono.git] / mcs / class / System.Web / System.Web.UI / DataSourceControl.cs
1 //
2 // System.Web.UI.DataSourceControl
3 //
4 // Authors:
5 //      Ben Maurer (bmaurer@users.sourceforge.net)
6 //
7 // (C) 2003 Ben Maurer
8 //
9
10 #if NET_2_0
11 using System.Collections;
12 using System.Collections.Specialized;
13 using System.Text;
14
15 namespace System.Web.UI {
16         public abstract class DataSourceControl : Control, IDataSource, System.ComponentModel.IListSource {
17
18
19                 protected DataSourceControl()
20                 {
21                 }
22                 
23                 protected override ControlCollection CreateControlCollection ()
24                 {
25                         return new EmptyControlCollection (this);
26                 }
27                 
28                 protected virtual DataSourceView GetView (string viewName)
29                 {
30                         return null;
31                 }
32                 
33                 DataSourceView IDataSource.GetView (string viewName)
34                 {
35                         return GetView (viewName);
36                 }
37                 
38                 protected virtual ICollection GetViewNames ()
39                 {
40                         return null;
41                 }
42                 
43                 ICollection IDataSource.GetViewNames ()
44                 {
45                         return GetViewNames ();
46                 }
47
48                 IList System.ComponentModel.IListSource.GetList ()
49                 {
50                         return ListSourceHelper.GetList (this);
51                 }
52                 
53                 bool System.ComponentModel.IListSource.ContainsListCollection {
54                         get { return ListSourceHelper.ContainsListCollection (this); }
55                 }
56
57                 //public override bool EnablePersonalization { get; set; }
58                 //public override bool EnableTheming { get; set; }
59                 //public override string SkinID { get; set; }
60                 public override bool Visible { 
61                         get { return false; }
62                         set { throw new NotSupportedException (); }
63                 }
64
65                 static object dataSourceChanged = new object ();
66                 event EventHandler System.Web.UI.IDataSource.DataSourceChanged {
67                         add { Events.AddHandler (dataSourceChanged, value); }
68                         remove { Events.RemoveHandler (dataSourceChanged, value); }
69                 }
70                 
71                 protected virtual void OnDataSourceChanged (EventArgs e)
72                 {
73                         EventHandler eh = Events [dataSourceChanged] as EventHandler;
74                         if (eh != null)
75                                 eh (this, e);
76                 }
77         }
78 }
79 #endif
80