diff options
author | Gaurav Vaish <gvaish@mono-cvs.ximian.com> | 2002-02-01 13:09:51 +0300 |
---|---|---|
committer | Gaurav Vaish <gvaish@mono-cvs.ximian.com> | 2002-02-01 13:09:51 +0300 |
commit | 22690d7f339669173fe88cc46e8c8a5cff632e1f (patch) | |
tree | 26af681a76a7c00eeba05b881a5a081e1c5934a9 | |
parent | e09c86703b7cebbc67b16399b033c658afe49302 (diff) |
2002-02-01 Gaurav Vaish <gvaish@iitk.ac.in>
* DataList.cs -- Done a hell lot of work today. I am tired now and will
go to library to study for the exams on Monday.
See ChangeLog for details of what I did today.
* ChangeLog -- Updated in accordance.
svn path=/trunk/mcs/; revision=2219
-rw-r--r-- | mcs/class/System.Web/System.Web.UI.WebControls/ChangeLog | 25 | ||||
-rwxr-xr-x | mcs/class/System.Web/System.Web.UI.WebControls/DataList.cs | 607 |
2 files changed, 603 insertions, 29 deletions
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/ChangeLog b/mcs/class/System.Web/System.Web.UI.WebControls/ChangeLog index 80f25156cd3..297b88b41b1 100644 --- a/mcs/class/System.Web/System.Web.UI.WebControls/ChangeLog +++ b/mcs/class/System.Web/System.Web.UI.WebControls/ChangeLog @@ -1,7 +1,32 @@ +2002-02-01 Gaurav Vaish <gvaish@iitk.ac.in> + + * TargetConverter.cs - Completed + * TemplateColumn.cs - Completed + * DataList.cs - Corrected the get-er methods for the *Style objects. + Corrected the get/set-er methods for ViewState related objects. + Addded support for properties: + GridLines, HeaderStyle, HeaderTemplate, ItemStyle, ItemTemplate, + RepeatColumns, RepeatDirection, RepeatLayout, SelectedIndex, SelectedItem, + SelectedItemStyle, SelectedItemTemplate, SeparatorStyle, SeparatorItemTemplate. + Events: + CancelCommand, DeleteCommand, EditCommand, ItemCommand, ItemCreated, + ItemDataBound, UpdateCommand. + Methods: + CreateControlStyle(), LoadViewState(object), SaveViewState(), TrackViewState + Event handlers: + OnBubbleEvent, OnCancelCommand, OnDeleteCommand, OnEditCommand, OnItemCommand, + OnItemCreated, OnItemDataBound, OnUpdateCommand + Added dummy methods for some undocumented methods: + CreateControlHierarchy(bool), CreateItem(int, ListItemType), + CreateItem(int, ListItemType, bool, object), PrepareControlHierarchy(), + InitializeItem(DataListItem) + + 2002-01-31 Gaurav Vaish <gvaish@iitk.ac.in> * RepeaterInfo.cs - Initial Implementation. Done all except for RepeatDirection.Vertical + * TableStyle.cs - Completed 2002-01-30 Gaurav Vaish <gvaish@iitk.ac.in> diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/DataList.cs b/mcs/class/System.Web/System.Web.UI.WebControls/DataList.cs index 199c255d3b5..7636e4b0f2b 100755 --- a/mcs/class/System.Web/System.Web.UI.WebControls/DataList.cs +++ b/mcs/class/System.Web/System.Web.UI.WebControls/DataList.cs @@ -26,12 +26,21 @@ namespace System.Web.UI.WebControls public const string EditCommandName = "Edit";
public const string SelectCommandName = "Select";
public const string UpdateCommandName = "Update";
+
+ private static readonly object CancelCommandEvent = new object();
+ private static readonly object DeleteCommandEvent = new object();
+ private static readonly object EditCommandEvent = new object();
+ private static readonly object ItemCommandEvent = new object();
+ private static readonly object ItemCreatedEvent = new object();
+ private static readonly object ItemDataBoundEvent = new object();
+ private static readonly object UpdateCommandEvent = new object();
- //TODO: From where will I update the values of the following ItemStyles?
private TableItemStyle alternatingItemStyle;
private TableItemStyle editItemStyle;
private TableItemStyle footerStyle;
private TableItemStyle headerStyle;
+ private TableItemStyle itemStyle;
+ private TableItemStyle selectedItemStyle;
private TableItemStyle separatorStyle;
private ITemplate alternatingItemTemplate;
@@ -40,33 +49,23 @@ namespace System.Web.UI.WebControls private ITemplate headerTemplate;
private ITemplate separatorTemplate;
- private int editItemIndex;
- private bool extractTemplateRows;
-
private ArrayList itemsArray;
+ private DataListItemCollection items;
- public DataList()
+ public DataList(): base()
{
- alternatingItemStyle = new TableItemStyle();
- editItemStyle = new TableItemStyle();
- footerStyle = new TableItemStyle();
- headerStyle = new TableItemStyle();
-
- alternatingItemTemplate = null;
- editItemTemplate = null;
- footerTemplate = null;
- headerTemplate = null;
- separatorTemplate = null;
-
- extractTemplateRows = false;
-
- itemsArray = null;
}
public virtual TableItemStyle AlternatingItemStyle
{
get
{
+ if(alternatingItemStyle == null)
+ {
+ alternatingItemStyle = new TableItemStyle();
+ if(IsTrackingViewState())
+ alternatingItemStyle.TrackViewState();
+ }
return alternatingItemStyle;
}
}
@@ -87,11 +86,14 @@ namespace System.Web.UI.WebControls {
get
{
- return editItemIndex;
+ object o = ViewState["EditItemIndex"];
+ if(o != null)
+ return (int)o;
+ return -1;
}
set
{
- editItemIndex = value;
+ ViewState["EditItemIndex"] = value;
}
}
@@ -99,12 +101,14 @@ namespace System.Web.UI.WebControls {
get
{
+ if(editItemStyle == null)
+ {
+ editItemStyle = new TableItemStyle();
+ if(IsTrackingViewState())
+ editItemStyle.TrackViewState();
+ }
return editItemStyle;
}
- set
- {
- editItemStyle = value;
- }
}
public virtual ITemplate EditItemTemplate
@@ -123,11 +127,14 @@ namespace System.Web.UI.WebControls {
get
{
- return extractTemplateRows;
+ object o = ViewState["ExtractTemplateRows"];
+ if(o != null)
+ return (bool)o;
+ return false;
}
set
{
- extractTemplateRows = value;
+ ViewState["ExtractTemplateRows"] = value;
}
}
@@ -135,7 +142,13 @@ namespace System.Web.UI.WebControls {
get
{
- return footerStyle;
+ if(footerStyle == null)
+ {
+ footerStyle = new TableItemStyle();
+ if(IsTrackingViewState())
+ footerItemStyle.TrackViewState();
+ }
+ return footerItemStyle;
}
}
@@ -151,6 +164,243 @@ namespace System.Web.UI.WebControls }
}
+ public override GridLines GridLines
+ {
+ get
+ {
+ return GridLines;
+ }
+ set
+ {
+ GridLines = value;
+ }
+ }
+
+ public virtual TableItemStyle HeaderStyle
+ {
+ get
+ {
+ if(headerStyle == null)
+ {
+ headerStyle = new TableItemStyle();
+ if(IsTrackingViewState())
+ headerStyle.TrackViewState();
+ }
+ return headerStyle;
+ }
+ }
+
+ public virtual ITemplate HeaderTemplate
+ {
+ get
+ {
+ return headerTemplate;
+ }
+ set
+ {
+ headerTemplate = value;
+ }
+ }
+
+ public virtual DataListItemCollection Items
+ {
+ get
+ {
+ if(items == null)
+ {
+ if(itemsArray = null)
+ {
+ EnsureChildControls();
+ itemsArray = new ArrayList();
+ }
+ items = new DataListItemCollection(itemsArray);
+ }
+ return items;
+ }
+ }
+
+ public virtual TableItemStyle ItemStyle
+ {
+ get
+ {
+ if(itemStyle == null)
+ {
+ itemStyle = new TableItemStyle();
+ if(IsTrackingViewState())
+ itemStyle.TrackViewState();
+ }
+ return itemStyle;
+ }
+ }
+
+ public virtual ITemplate ItemTemplate
+ {
+ get
+ {
+ return itemTemplate;
+ }
+ set
+ {
+ itemTemplate = value;
+ }
+ }
+
+ public virtual int RepeatColumns
+ {
+ get
+ {
+ object o = ViewState["RepeatColumns"];
+ if(o != null)
+ return (int)o;
+ return 0;
+ }
+ set
+ {
+ if(value < 0)
+ throw new ArgumentOutOfRangeException("value");
+ ViewState["RepeatColumns"] = value;
+ }
+ }
+
+ public virtual RepeatDirection RepeatDirection
+ {
+ get
+ {
+ object o = ViewState["RepeatDirection"];
+ if(o != null)
+ return (RepeatDirection)o;
+ return RepeatDirection.Vertical;
+ }
+ set
+ {
+ if(!Enum.IsDefined(typeof(RepeatDirection), value))
+ throw new ArgumentException();
+ ViewState["RepeatDirection"] = value;
+ }
+ }
+
+ public virtual RepeatLayout RepeatLayout
+ {
+ get
+ {
+ object o = ViewState["RepeatLayout"];
+ if(o != null)
+ return (RepeatLayout)o;
+ return RepeatLayout.Table;
+ }
+ set
+ {
+ if(!Enum.IsDefined(typeof(RepeatLayout), value))
+ throw new ArgumentException();
+ ViewState["RepeatLayout"] = value;
+ }
+ }
+
+ public virtual int SelectedIndex
+ {
+ get
+ {
+ object o = ViewState["SelectedIndex"];
+ if(o != null)
+ return (int)o;
+ return -1;
+ }
+ set
+ {
+ //FIXME: Looks like a bug in Microsoft's specs.
+ // Exception is missing in document. I haven't tested the case
+ // But I think exception should follow
+ if(value < -1)
+ throw ArgumentOutOfRangeException("value");
+ int prevSel = SelectedIndex;
+ ViewState["SelectedIndex"] = value;
+ DataListItem prevSelItem;
+ ListItemType liType;
+ if(itemsArray != null)
+ {
+ if(prevSel >= 0 && prevSel < itemsArray.Count)
+ {
+ prevSelItem = (DataListItem)itemsArray[prevSel];
+ if(prevSelItem.ItemType != ListItemType.EditItem)
+ {
+ liType = ( (prevSel % 2) == 0 ? ListItemType.AlternatingItem : ListItemType.Item );
+ prevSelItem.SetItemType(liType);
+ }
+ }
+ if(value >= 0 && value < itemsArray.Count)
+ {
+ prevSelItem = (DataListItem) iteamArray[value];
+ if(prevSelItem.ItemType != ListItemType.EditItem)
+ {
+ prevSelItem.SetItemType(ListItemType.SelectedItem);
+ }
+ }
+ }
+ }
+ }
+
+ public virtual DataListItem SelectedItem
+ {
+ get
+ {
+ if(SelectedIndex == -1)
+ return null;
+ return Items[SelectedIndex];
+ }
+ }
+
+ public virtual TableItemStyle SelectedItemStyle
+ {
+ get
+ {
+ if(selectedItemStyle == null)
+ {
+ selectedItemStyle = new TableItemStyle();
+ if(IsTrackingViewState())
+ selectedItemStyle.TrackViewState();
+ }
+ return selectedItemStyle;
+ }
+ }
+
+ public virtual ITemplate SelectedItemTemplate
+ {
+ get
+ {
+ return selectedItemTemplate;
+ }
+ set
+ {
+ selectedItemTemplate = value;
+ }
+ }
+
+ public virtual TableItemStyle SeparatorStyle
+ {
+ get
+ {
+ if(separatorStyle == null)
+ {
+ separatorStyle = new TableItemStyle();
+ if(IsTrackingViewState())
+ separatorStyle.TrackViewState();
+ }
+ return separatorStyle;
+ }
+ }
+
+ public virtual ITemplate SeparatorItemTemplate
+ {
+ get
+ {
+ return separatorItemTemplate;
+ }
+ set
+ {
+ separatorItemTemplate = value;
+ }
+ }
+
public virtual bool ShowHeader
{
get
@@ -180,12 +430,284 @@ namespace System.Web.UI.WebControls ViewState["ShowFooter"] = value;
}
}
+
+ public event DataListCommandEventHandler CancelCommand
+ {
+ add
+ {
+ Events.AddHandler(CancelCommandEvent, value);
+ }
+ remove
+ {
+ Events.RemoveHandler(CancelCommandEvent, value);
+ }
+ }
+
+ public event DataListCommandEventHandler DeleteCommand
+ {
+ add
+ {
+ Events.AddHandler(DeleteCommandEvent, value);
+ }
+ remove
+ {
+ Events.RemoveHandler(DeleteCommandEvent, value);
+ }
+ }
+
+ public event DataListCommandEventHandler EditCommand
+ {
+ add
+ {
+ Events.AddHandler(EditCommandEvent, value);
+ }
+ remove
+ {
+ Events.RemoveHandler(EditCommandEvent, value);
+ }
+ }
+
+ public event DataListCommandEventHandler ItemCommand
+ {
+ add
+ {
+ Events.AddHandler(ItemCommandEvent, value);
+ }
+ remove
+ {
+ Events.RemoveHandler(ItemCommandEvent, value);
+ }
+ }
+
+ public event DataListCommandEventHandler ItemCreated
+ {
+ add
+ {
+ Events.AddHandler(ItemCreatedEvent, value);
+ }
+ remove
+ {
+ Events.RemoveHandler(ItemCreatedEvent, value);
+ }
+ }
+
+ public event DataListCommandEventHandler ItemDataBound
+ {
+ add
+ {
+ Events.AddHandler(ItemDataBoundEvent, value);
+ }
+ remove
+ {
+ Events.RemoveHandler(ItemDataBoundEvent, value);
+ }
+ }
+
+ public event DataListCommandEventHandler UpdateCommand
+ {
+ add
+ {
+ Events.AddHandler(UpdateCommandEvent, value);
+ }
+ remove
+ {
+ Events.RemoveHandler(UpdateCommandEvent, value);
+ }
+ }
+
+ protected override Style CreateControlStyle()
+ {
+ TableStyle retVal = new TableStyle(StateBag);
+ retVal.CellSpacing = 0;
+ return retVal;
+ }
+
+ protected override void LoadViewState(object savedState)
+ {
+ object[] states;
+ if(savedState != null && (states = (object[])savedState) != null)
+ {
+ if(states[0] != null)
+ LoadViewState(states[0]);
+ if(states[1] != null)
+ alternatingItemStyle.LoadViewState(states[1]);
+ if(states[2] != null)
+ editItemStyle.LoadViewState(states[2]);
+ if(states[3] != null)
+ footerStyle.LoadViewState(states[3]);
+ if(states[4] != null)
+ headerStyle.LoadViewState(states[4]);
+ if(states[5] != null)
+ itemStyle.LoadViewState(states[5]);
+ if(states[6] != null)
+ selectedItemStyle.LoadViewState(states[6]);
+ if(states[7] != null)
+ separatorStyle.LoadViewState(states[7]);
+ }
+ }
+ protected override object SaveViewState()
+ {
+ object[] states = new object[8];
+ states[0] = SaveViewState();
+ states[1] = (alternatingItemStyle == null ? null : alternatingItemStyle.SaveViewState());
+ states[2] = (editItemStyle == null ? null : editItemStyle.SaveViewState());
+ states[3] = (footerStyle == null ? null : footerStyle.SaveViewState());
+ states[4] = (headerStyle == null ? null : headerStyle.SaveViewState());
+ states[5] = (itemStyle == null ? null : itemStyle.SaveViewState());
+ states[6] = (selectedItemStyle == null ? null : selectedItemStyle.SaveViewState());
+ states[7] = (separatorStyle == null ? null : separatorStyle.SaveViewState());
+ return states;
+ }
+
+ protected override void TrackViewState()
+ {
+ TrackViewState();
+ if(alternatingItemStyle != null)
+ alternatingItemStyle.TrackViewState();
+ if(editItemStyle != null)
+ editItemStyle.TrackViewState();
+ if(footerStyle != null)
+ footerStyle.TrackViewState();
+ if(headerStyle != null)
+ headerStyle.TrackViewState();
+ if(itemStyle != null)
+ itemStyle.TrackViewState();
+ if(selectedItemStyle != null)
+ selectedItemStyle.TrackViewState();
+ if(separatorStyle != null)
+ separatorStyle.TrackViewState();
+ }
+
+ protected override bool OnBubbleEvent(object source, EventArgs e)
+ {
+ bool retVal;
+ if(e is DataListCommandEventArgs)
+ {
+ DataListCommandEventArgs dlcea = (DataListCommandEventArgs)e;
+ OnItemCommand(dlcea);
+ retVal = true;
+ if(String.Compare(dlcea.CommandName, "Cancel") == 0)
+ {
+ OnCancelCommand(dlcea);
+ }
+ if(String.Compare(dlcea.CommandName, "Delete") == 0)
+ {
+ OnDeleteCommand(dlcea);
+ }
+ if(String.Compare(dlcea.CommandName, "Edit") == 0)
+ {
+ OnEditCommand(dlcea);
+ }
+ if(String.Compare(dlcea.CommandName, "Select") == 0)
+ {
+ OnSelectCommand(dlcea);
+ }
+ if(String.Compare(dlcea.CommandName, "Update") == 0)
+ {
+ OnUpdateCommand(dlcea);
+ }
+ }
+ return retVal;
+ }
+
+ protected virtual void OnCancelCommand(DataListCommandEventArgs e)
+ {
+ if(Events != null)
+ {
+ DataListCommandEventHandler dlceh = (DataListCommandEventHandler)(Events[CancelCommandEvent]);
+ if(dlceh != null)
+ dlceh(this, e);
+ }
+ }
+
+ protected virtual void OnDeleteCommand(DataListCommandEventArgs e)
+ {
+ if(Events != null)
+ {
+ DataListCommandEventHandler dlceh = (DataListCommandEventHandler)(Events[DeleteCommandEvent]);
+ if(dlceh != null)
+ dlceh(this, e);
+ }
+ }
+
+ protected virtual void OnEditCommand(DataListCommandEventArgs e)
+ {
+ if(Events != null)
+ {
+ DataListCommandEventHandler dlceh = (DataListCommandEventHandler)(Events[EditCommandEvent]);
+ if(dlceh != null)
+ dlceh(this, e);
+ }
+ }
+
+ protected virtual void OnItemCommand(DataListCommandEventArgs e)
+ {
+ if(Events != null)
+ {
+ DataListCommandEventHandler dlceh = (DataListCommandEventHandler)(Events[ItemCommandEvent]);
+ if(dlceh != null)
+ dlceh(this, e);
+ }
+ }
+
+ protected virtual void OnItemCreated(DataListCommandEventArgs e)
+ {
+ if(Events != null)
+ {
+ DataListCommandEventHandler dlceh = (DataListCommandEventHandler)(Events[ItemCreatedEvent]);
+ if(dlceh != null)
+ dlceh(this, e);
+ }
+ }
+
+ protected virtual void OnItemDataBound(DataListCommandEventArgs e)
+ {
+ if(Events != null)
+ {
+ DataListCommandEventHandler dlceh = (DataListCommandEventHandler)(Events[ItemDataBoundEvent]);
+ if(dlceh != null)
+ dlceh(this, e);
+ }
+ }
+
+ protected virtual void OnUpdateCommand(DataListCommandEventArgs e)
+ {
+ if(Events != null)
+ {
+ DataListCommandEventHandler dlceh = (DataListCommandEventHandler)(Events[UpdateCommandEvent]);
+ if(dlceh != null)
+ dlceh(this, e);
+ }
+ }
[MonoTODO]
- private DataListItem GetItem(ListItemType itemType, int repeatIndex)
+ protected override void RenderContents(HtmlTextWriter writer)
{
throw new NotImplementedException();
}
+
+ [MonoTODO]
+ private DataListItem GetItem(ListItemType itemType, int repeatIndex)
+ {
+ DataListItem retVal = null;
+ switch(itemType)
+ {
+ case ListItemType.Header: retVal = (DataListitem)Controls[0];
+ break;
+ case ListItemType.Footer: retVal = (DataListItem)Controls[Controls.Count - 1];
+ break;
+ case ListItemType.Item: goto case ListItemType.EditItem;
+ case ListItemType.AlternatingItem: goto case ListItemType.EditItem;
+ case ListItemType.SelectedItem: goto case ListItemType.EditItem;
+ case ListItemType.EditItem: retVal = (DataListItem)Controls[repeatIndex];
+ break;
+ case ListItemType.Separator: int index = 2 * repeatIndex + 1;
+ if(headerTemplate != null)
+ index ++;
+ retVal = (DataListItem)Controls[index];
+ }
+ return retVal;
+ }
/// <summary>
/// Undocumented
@@ -200,11 +722,38 @@ namespace System.Web.UI.WebControls /// Undocumented
/// </summary>
[MonoTODO]
+ protected DataListItem CreateItem(int itemIndex, ListItemType itemType)
+ {
+
+ }
+
+ /// <summary>
+ /// Undocumented
+ /// </summary>
+ [MonoTODO]
+ protected DataListItem CreateItem(int itemIndex, ListItemType itemType, bool dataBind, object dataItem)
+ {
+
+ }
+
+ /// <summary>
+ /// Undocumented
+ /// </summary>
+ [MonoTODO]
protected override void PrepareControlHierarchy()
{
throw new NotImplementedException();
}
+ /// <summary>
+ /// Undocumented
+ /// </summary>
+ [MonoTODO]
+ protected void InitializeItem(DataListItem item)
+ {
+ throw new NotImplementedException();
+ }
+
bool IRepeatInfoUser.HasFooter
{
get
|