Files
mono/mcs/class/System.Web/System.Web.UI.WebControls/BaseDataList.cs
T
Andreas N 0fc9b50a1a 2003-08-01 Andreas Nahr <[email protected]>
* AdRotator.cs: Added all attributes
	* BaseDataList.cs: Added all attributes, added lamespec, removed additional attributes
	* BaseValidator.cs: Added all attributes
	* BoundColumn.cs: Added all attributes
	* Button.cs: Added all attributes
	* ButtonColumn.cs: Added all attributes, added lamespec
	* Calendar.cs: Added all attributes, added error checks, throws more exceptions
	* CheckBox.cs: Added all attributes
	* CheckBoxList.cs: Added all attributes
	* CompareValidator.cs: Added all attributes
	* CustomValidator.cs: Added all attributes
	* DataGrid.cs: Added all attributes, more verbose exceptions, fixed signature, removed additional attributes
	* DataGridColumn.cs: Added all attributes
	* DataGridColumnCollection.cs: Added all attributes
	* DataGridPagerStyle.cs: Added all attributes
	* DataGridTableInternal.cs: Made DataGridTableInternal internal
	* DataList.cs: Added all attributes, more verbose exceptions, removed non-existing member
	* DropDownList.cs: Added all attributes
	* FontInfo.cs: Added all attributes
	* HyperLink.cs: Added all attributes
	* HyperLinkColumn.cs: Added all attributes
	* Image.cs: Added all attributes
	* ImageButton.cs: Added all attributes
	* Label.cs: Added all attributes
	* LinkButton.cs: Added all attributes
	* ListBox.cs: Added all attributes, added error checks, throws more exceptions
	* ListControl.cs: Added all attributes
	* ListItem.cs: Added all attributes
	* ListItemCollection.cs: Added attribute
	* Literal.cs: Added all attributes
	* Panel.cs: Added all attributes
	* RadioButton.cs: Added all attributes
	* RadioButtonList.cs: Added all attributes, added error checks, throws more exceptions
	* RangeValidator.cs: Added all attributes
	* RegularExpressionValidator.cs: Added all attributes
	* Repeater.cs: Added all attributes

svn path=/trunk/mcs/; revision=16985
2003-08-01 08:04:00 +00:00

278 lines
6.0 KiB
C#
Executable File

//
// System.Web.UI.WebControls.BaseDataList.cs
//
// Authors:
// Gaurav Vaish ([email protected])
// Andreas Nahr ([email protected])
//
// (C) Gaurav Vaish (2001)
// (C) 2003 Andreas Nahr
//
using System;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Collections;
using System.Web;
using System.Web.UI;
namespace System.Web.UI.WebControls
{
[DefaultEvent("SelectedIndexChanged")]
[DefaultProperty("DataSource")]
[Designer("System.Web.UI.Design.WebControls.BaseDataListDesigner, " + Consts.AssemblySystem_Design, typeof (IDesigner))]
public abstract class BaseDataList: WebControl
{
private static readonly object SelectedIndexChangedEvent = new object();
internal static string ItemCountViewStateKey = "_!ItemCount";
private DataKeyCollection dataKeys;
private object dataSource;
public BaseDataList() : base()
{
}
public static bool IsBindableType(Type type)
{
if(type.IsPrimitive || type == typeof(string) || type == typeof(DateTime) || type == typeof(Decimal))
return true;
return false;
}
public override ControlCollection Controls
{
get
{
EnsureChildControls();
return base.Controls;
}
}
public override void DataBind()
{
OnDataBinding(EventArgs.Empty);
}
[WebCategory("Action")]
[WebSysDescription("BaseDataList_OnSelectedIndexChanged")]
public event EventHandler SelectedIndexChanged
{
add
{
Events.AddHandler(SelectedIndexChangedEvent, value);
}
remove
{
Events.RemoveHandler(SelectedIndexChangedEvent, value);
}
}
[Bindable(true)]
[DefaultValue(-1)]
[WebCategory("Layout")]
[WebSysDescription("BaseDataList_CellPadding")]
public virtual int CellPadding
{
get
{
if(!ControlStyleCreated)
return -1;
return ((TableStyle)ControlStyle).CellPadding;
}
set
{
((TableStyle)ControlStyle).CellPadding = value;
}
}
[Bindable(true)]
[DefaultValue(-1)]
[WebCategory("Layout")]
[WebSysDescription("BaseDataList_CellSpacing")]
public virtual int CellSpacing
{
get
{
if(!ControlStyleCreated)
return -1;
return ((TableStyle)ControlStyle).CellSpacing;
}
set
{
((TableStyle)ControlStyle).CellSpacing = value;
}
}
[DefaultValue("")]
[WebCategory("Data")]
[WebSysDescription("BaseDataList_DataKeyField")]
public virtual string DataKeyField
{
get
{
object o = ViewState["DataKeyField"];
if(o!=null)
return (string)o;
return String.Empty;
}
set
{
ViewState["DataKeyField"] = value;
}
}
[Browsable(true)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
[WebSysDescription("BaseDataList_DataKeys")]
public DataKeyCollection DataKeys
{
get
{
if( dataKeys==null )
dataKeys = new DataKeyCollection(DataKeysArray);
return dataKeys;
}
}
[DefaultValue("")]
[WebCategory("Data")]
[WebSysDescription("BaseDataList_DataMember")]
public string DataMember
{
get
{
object o = ViewState["DataMember"];
if(o!=null)
return (string)o;
return String.Empty;
}
set
{
ViewState["DataMember"] = value;
}
}
[Bindable(true)]
[DefaultValue(null)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
[WebCategory("Data")]
[WebSysDescription("BaseDataList_DataSource")]
public virtual object DataSource
{
get
{
return dataSource;
}
set
{
if( (value!=null) && (value is IListSource || value is IEnumerable) )
{
dataSource = value;
} else
{
throw new ArgumentException(HttpRuntime.FormatResourceString("Invalid_DataSource_Type", ID));
}
}
}
[Bindable(true)]
[DefaultValue(GridLines.Both)]
[WebCategory("Appearance")]
[WebSysDescription("BaseDataList_GridLines")]
public virtual GridLines GridLines
{
get
{
if(ControlStyleCreated)
return ((TableStyle)ControlStyle).GridLines;
return GridLines.Both;
}
set
{
((TableStyle)ControlStyle).GridLines = value;
}
}
// LAMESPEC HorizontalAlign has a Category attribute, this should obviously be a WebCategory attribute
// but is defined incorrectly in the MS framework
[Bindable(true)]
[DefaultValue(HorizontalAlign.NotSet)]
[Category("Layout")]
[WebSysDescription("BaseDataList_HorizontalAlign")]
public virtual HorizontalAlign HorizontalAlign
{
get
{
if(ControlStyleCreated)
return ((TableStyle)ControlStyle).HorizontalAlign;
return HorizontalAlign.NotSet;
}
set
{
((TableStyle)ControlStyle).HorizontalAlign = value;
}
}
protected ArrayList DataKeysArray
{
get
{
object o = ViewState["DataKeys"];
if(o == null)
{
o = new ArrayList();
ViewState["DataKeys"] = o;
}
return (ArrayList)o;
}
}
protected override void AddParsedSubObject(object o)
{
// Preventing literal controls from being added as children.
}
protected override void CreateChildControls()
{
Controls.Clear();
if(ViewState[ItemCountViewStateKey]!=null)
{
CreateControlHierarchy(false);
ClearChildViewState();
}
}
protected override void OnDataBinding(EventArgs e)
{
base.OnDataBinding(e);
Controls.Clear();
ClearChildViewState();
CreateControlHierarchy(true);
ChildControlsCreated = true;
TrackViewState();
}
protected virtual void OnSelectedIndexChanged(EventArgs e)
{
if(Events != null)
{
EventHandler eh = (EventHandler)(Events[SelectedIndexChangedEvent]);
if(eh!=null)
eh(this, e);
}
}
protected override void Render(HtmlTextWriter writer)
{
PrepareControlHierarchy();
RenderContents(writer);
}
protected abstract void PrepareControlHierarchy();
protected abstract void CreateControlHierarchy(bool useDataSource);
}
}