| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112 |
- //
- // System.Web.UI.WebControls.ListView
- //
- // Authors:
- // Marek Habersack ([email protected])
- //
- // (C) 2007 Novell, Inc
- //
- //
- // Permission is hereby granted, free of charge, to any person obtaining
- // a copy of this software and associated documentation files (the
- // "Software"), to deal in the Software without restriction, including
- // without limitation the rights to use, copy, modify, merge, publish,
- // distribute, sublicense, and/or sell copies of the Software, and to
- // permit persons to whom the Software is furnished to do so, subject to
- // the following conditions:
- //
- // The above copyright notice and this permission notice shall be
- // included in all copies or substantial portions of the Software.
- //
- // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
- // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
- // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- //
- #if NET_3_5
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.Collections.Specialized;
- using System.ComponentModel;
- using System.Drawing;
- using System.Web;
- using System.Web.UI;
- using System.Web.UI.HtmlControls;
- namespace System.Web.UI.WebControls
- {
- [DefaultEventAttribute ("SelectedIndexChanged")]
- [ControlValuePropertyAttribute ("SelectedValue")]
- [DesignerAttribute ("System.Web.UI.Design.WebControls.ListViewDesigner, System.Web.Extensions.Design, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35")]
- [SupportsEventValidationAttribute ()]
- [ToolboxBitmapAttribute (typeof (ListView), "ListView.ico")]
- [DefaultPropertyAttribute ("SelectedValue")]
- public class ListView : DataBoundControl, INamingContainer, IPageableItemContainer
- {
- ITemplate _emptyDataTemplate;
- ITemplate _emptyItemTemplate;
- ITemplate _insertItemTemplate;
- ITemplate _groupSeparatorTemplate;
- ITemplate _groupTemplate;
- ITemplate _itemSeparatorTemplate;
- ITemplate _itemTemplate;
- ITemplate _selectedItemTemplate;
- ITemplate _alternatingItemTemplate;
- ITemplate _editItemTemplate;
- ITemplate _layoutTemplate;
- int _startRowIndex;
- int _maximumRows;
- int _selectedIndex;
- int _editIndex;
- int _groupItemCount;
- string [] _dataKeyNames;
- DataKeyArray _dataKeys;
- ArrayList _dataKeyArray;
- SortDirection _sortDirection = SortDirection.Ascending;
- string _sortExpression = String.Empty;
- Control _layoutTemplatePlaceholder;
- IOrderedDictionary _lastInsertValues;
-
- public ListView ()
- {
- InsertItemPosition = InsertItemPosition.None;
- }
-
- protected virtual void AddControlToContainer (Control control, Control container, int addLocation)
- {
- if (control == null || container == null)
- return;
- Control ctl;
- if (container is HtmlTable) {
- ctl = new ListViewTableRow ();
- ctl.Controls.Add (control);
- } else
- ctl = control;
-
- container.Controls.AddAt (addLocation, ctl);
- }
-
- protected internal override void CreateChildControls ()
- {
- if (RequiresDataBinding)
- EnsureDataBound ();
-
- base.CreateChildControls ();
- }
-
- protected virtual int CreateChildControls (IEnumerable dataSource, bool dataBinding)
- {
- IList <ListViewDataItem> retList = null;
- EnsureLayoutTemplate ();
- RemoveItems ();
- bool haveDataToDisplay = _maximumRows > 0 && _startRowIndex > 0;
- var pagedDataSource = new ListViewPagedDataSource ();
-
- if (dataBinding) {
- DataSourceView view = GetData ();
- if (view == null)
- throw new InvalidOperationException ("dataSource returned a null reference for DataSourceView.");
- if (!(dataSource is ICollection))
- throw new InvalidOperationException ("dataSource does not implement the ICollection interface.");
- int totalRowCount = 0;
- if (haveDataToDisplay) {
- if (view.CanRetrieveTotalRowCount)
- totalRowCount = SelectArguments.TotalRowCount;
- else
- totalRowCount = ((ICollection) dataSource).Count + _startRowIndex;
- }
-
- pagedDataSource.StartRowIndex = _startRowIndex;
- pagedDataSource.DataSource = dataSource;
- pagedDataSource.TotalRowCount = totalRowCount;
- } else {
- if (!(dataSource is ICollection))
- throw new InvalidOperationException ("dataSource does not implement the ICollection interface and dataBinding is false.");
- }
- if (GroupItemCount <= 0) {
- retList = CreateItemsWithoutGroups (pagedDataSource, dataBinding, InsertItemPosition, DataKeyArray);
- Console.WriteLine ("Data key names:");
- foreach (string s in DataKeyNames)
- Console.WriteLine ("\t{0}", s);
-
- Console.WriteLine ("Keys:");
- foreach (object o in DataKeyArray)
- Console.WriteLine ("\t{0}", o);
- }
-
- if (retList == null)
- return 0;
- return retList.Count;
- }
-
- protected override Style CreateControlStyle ()
- {
- throw StylingNotSupported ();
- }
-
- protected virtual ListViewDataItem CreateDataItem (int dataItemIndex, int displayIndex)
- {
- return new ListViewDataItem (dataItemIndex, displayIndex);
- }
-
- protected override DataSourceSelectArguments CreateDataSourceSelectArguments ()
- {
- DataSourceSelectArguments arg = DataSourceSelectArguments.Empty;
- DataSourceView view = GetData();
-
- if (view.CanPage) {
- arg.StartRowIndex = _startRowIndex;
- if (view.CanRetrieveTotalRowCount) {
- arg.RetrieveTotalRowCount = true;
- arg.MaximumRows = _maximumRows;
- } else
- arg.MaximumRows = -1;
- }
- if (IsBoundUsingDataSourceID && !String.IsNullOrEmpty (_sortExpression)) {
- if (_sortDirection == SortDirection.Ascending)
- arg.SortExpression = _sortExpression;
- else
- arg.SortExpression = _sortExpression + " DESC";
- }
-
- return arg;
- }
-
- protected virtual void CreateEmptyDataItem ()
- {
- if (_emptyDataTemplate != null) {
- ListViewItem item = CreateItem (ListViewItemType.EmptyItem);
- InstantiateEmptyDataTemplate (item);
- OnItemCreated (new ListViewItemEventArgs (item));
- AddControlToContainer (item, this, 0);
- }
- }
-
- protected virtual ListViewItem CreateEmptyItem ()
- {
- if (_emptyDataTemplate != null) {
- ListViewItem item = CreateItem (ListViewItemType.EmptyItem);
- InstantiateEmptyItemTemplate (item);
- OnItemCreated (new ListViewItemEventArgs (item));
- return item;
- }
- return null;
- }
-
- protected virtual ListViewItem CreateInsertItem ()
- {
- ListViewItem ret = CreateItem (ListViewItemType.InsertItem);
- InsertItem = ret;
- return ret;
- }
-
- protected virtual ListViewItem CreateItem (ListViewItemType itemType)
- {
- return new ListViewItem (itemType);
- }
-
- protected virtual IList <ListViewDataItem> CreateItemsInGroups (ListViewPagedDataSource dataSource, bool dataBinding, InsertItemPosition insertPosition,
- ArrayList keyArray)
- {
- if (_groupTemplate == null)
- return null;
-
- throw new NotImplementedException ();
- }
-
- protected virtual IList <ListViewDataItem> CreateItemsWithoutGroups (ListViewPagedDataSource dataSource, bool dataBinding,
- InsertItemPosition insertPosition, ArrayList keyArray)
- {
- Control contentPlaceholder = FindPlaceholder (ItemPlaceholderID, _layoutTemplatePlaceholder);
-
- if (contentPlaceholder == null)
- return new List <ListViewDataItem> ();
- Control parent = contentPlaceholder.Parent;
- int ipos = 0;
-
- if (parent != null) {
- ipos = parent.Controls.IndexOf (contentPlaceholder);
- parent.Controls.Remove (contentPlaceholder);
- contentPlaceholder = parent;
- AddControlToContainer (contentPlaceholder, _layoutTemplatePlaceholder, 0);
- }
- List <ListViewDataItem> ret = new List <ListViewDataItem> ();
- ListViewItem lvi;
- ListViewItem container;
- bool needSeparator = false;
- if (insertPosition == InsertItemPosition.FirstItem) {
- lvi = CreateInsertItem ();
- InstantiateInsertItemTemplate (lvi);
- AddControlToContainer (lvi, contentPlaceholder, ipos++);
- needSeparator = true;
- }
- bool haveSeparatorTemplate = _itemSeparatorTemplate != null;
- int displayIndex = 0;
- ListViewDataItem lvdi;
- int startIndex = dataSource.StartRowIndex;
-
- foreach (object item in dataSource) {
- if (needSeparator && haveSeparatorTemplate) {
- container = new ListViewItem ();
- InstantiateItemSeparatorTemplate (container);
- AddControlToContainer (container, contentPlaceholder, ipos++);
- }
- lvdi = CreateDataItem (startIndex + displayIndex, displayIndex);
- InstantiateItemTemplate (lvdi, displayIndex);
- if (dataBinding) {
- lvdi.DataItem = item;
- OrderedDictionary dict = new OrderedDictionary ();
- string[] dataKeyNames = DataKeyNames;
-
- foreach (string s in dataKeyNames)
- dict.Add (s, DataBinder.GetPropertyValue (item, s));
- DataKey dk = new DataKey (dict, dataKeyNames);
- if (keyArray.Count == displayIndex)
- keyArray.Add (dk);
- else
- keyArray [displayIndex] = dk;
- }
-
- OnItemCreated (new ListViewItemEventArgs (lvdi));
- AddControlToContainer (lvdi, contentPlaceholder, ipos++);
- if (!needSeparator)
- needSeparator = true;
- if (dataBinding) {
- lvdi.DataBind ();
- OnItemDataBound (new ListViewItemEventArgs (lvdi));
- }
- displayIndex++;
- ret.Add (lvdi);
- }
- if (insertPosition == InsertItemPosition.LastItem) {
- if (needSeparator && haveSeparatorTemplate) {
- container = new ListViewItem ();
- InstantiateItemSeparatorTemplate (container);
- AddControlToContainer (container, contentPlaceholder, ipos++);
- }
-
- lvi = CreateInsertItem ();
- InstantiateInsertItemTemplate (lvi);
- AddControlToContainer (lvi, contentPlaceholder, ipos++);
- }
-
- return ret;
- }
-
- protected virtual void CreateLayoutTemplate ()
- {
- if (_layoutTemplate != null) {
- _layoutTemplatePlaceholder = new Control ();
- _layoutTemplate.InstantiateIn (_layoutTemplatePlaceholder);
- AddControlToContainer (_layoutTemplatePlaceholder, this, 0);
- }
-
- OnLayoutCreated (EventArgs.Empty);
- }
-
- public virtual void DeleteItem (int itemIndex)
- {
- }
-
- protected virtual void EnsureLayoutTemplate ()
- {
- Controls.Clear ();
- CreateLayoutTemplate ();
- }
-
- public virtual void ExtractItemValues (IOrderedDictionary itemValues, ListViewItem item, bool includePrimaryKey)
- {
- if (itemValues == null)
- throw new ArgumentNullException ("itemValues");
-
- if (!(item is ListViewDataItem))
- throw new InvalidOperationException ("item is not a ListViewDataItem object.");
- }
-
- protected virtual Control FindPlaceholder (string containerID, Control container)
- {
- if (container == null || String.IsNullOrEmpty (containerID))
- return null;
- return container.FindControl (containerID);
- }
-
- public virtual void InsertNewItem (bool causesValidation)
- {
- ListViewItem insertItem = InsertItem;
- if (insertItem == null)
- throw new InvalidOperationException ("The ListView control does not have an insert item.");
- DataSourceView dsv = null;
- ListViewInsertEventArgs eventArgs = null;
-
- if (IsBoundUsingDataSourceID) {
- dsv = GetData ();
- if (dsv == null)
- throw new InvalidOperationException ("Missing data.");
- eventArgs = new ListViewInsertEventArgs (insertItem);
- ExtractItemValues (eventArgs.Values, insertItem, true);
- } else
- eventArgs = new ListViewInsertEventArgs (insertItem);
- OnItemInserting (eventArgs);
- if (!eventArgs.Cancel && IsBoundUsingDataSourceID) {
- _lastInsertValues = eventArgs.Values;
- dsv.Insert (_lastInsertValues, new DataSourceViewOperationCallback (InsertNewItemCallback));
- }
- }
- bool InsertNewItemCallback (int recordsAffected, Exception ex)
- {
- var eventArgs = new ListViewInsertedEventArgs (_lastInsertValues, recordsAffected, ex);
- OnItemInserted (eventArgs);
- _lastInsertValues = null;
- if (ex != null && !eventArgs.ExceptionHandled)
- return false;
- // This will effectively reset the insert values
- if (!eventArgs.KeepInInsertMode)
- RequiresDataBinding = true;
- return true;
- }
-
- protected virtual void InstantiateEmptyDataTemplate (Control container)
- {
- if (_emptyDataTemplate != null)
- _emptyDataTemplate.InstantiateIn (container);
- }
-
- protected virtual void InstantiateEmptyItemTemplate (Control container)
- {
- if (_emptyItemTemplate != null)
- _emptyItemTemplate.InstantiateIn (container);
- }
-
- protected virtual void InstantiateGroupSeparatorTemplate (Control container)
- {
- if (_groupSeparatorTemplate != null)
- _groupSeparatorTemplate.InstantiateIn (container);
- }
-
- protected virtual void InstantiateGroupTemplate (Control container)
- {
- if (_groupTemplate != null)
- _groupTemplate.InstantiateIn (container);
- }
-
- protected virtual void InstantiateInsertItemTemplate (Control container)
- {
- if (_insertItemTemplate != null)
- _insertItemTemplate.InstantiateIn (container);
- }
-
- protected virtual void InstantiateItemSeparatorTemplate (Control container)
- {
- if (_itemSeparatorTemplate != null)
- _itemSeparatorTemplate.InstantiateIn (container);
- }
-
- protected virtual void InstantiateItemTemplate (Control container, int displayIndex)
- {
- if (_itemTemplate == null)
- throw new InvalidOperationException ("ItemTemplate is missing");
- ITemplate template = _itemTemplate;
- if ((displayIndex % 2 != 0) && _alternatingItemTemplate != null)
- template = _alternatingItemTemplate;
-
- if ((displayIndex == _selectedIndex) && _selectedItemTemplate != null)
- template = _selectedItemTemplate;
- if ((displayIndex == _editIndex) && _editItemTemplate != null)
- template = _editItemTemplate;
- template.InstantiateIn (container);
- }
-
- protected override void LoadControlState (object savedState)
- {
- }
-
- protected override void LoadViewState (object savedState)
- {
- }
-
- protected override bool OnBubbleEvent (object source, EventArgs e)
- {
- throw new NotImplementedException ();
- }
-
- protected override void OnInit (EventArgs e)
- {
- }
-
- protected virtual void OnItemCanceling (ListViewCancelEventArgs e)
- {
- }
-
- protected virtual void OnItemCommand (ListViewCommandEventArgs e)
- {
- }
-
- protected virtual void OnItemCreated (ListViewItemEventArgs e)
- {
- }
-
- protected virtual void OnItemDataBound (ListViewItemEventArgs e)
- {
- }
-
- protected virtual void OnItemDeleted (ListViewDeletedEventArgs e)
- {
- }
-
- protected virtual void OnItemDeleting (ListViewDeleteEventArgs e)
- {
- }
-
- protected virtual void OnItemEditing (ListViewEditEventArgs e)
- {
- }
-
- protected virtual void OnItemInserted (ListViewInsertedEventArgs e)
- {
- }
-
- protected virtual void OnItemInserting (ListViewInsertEventArgs e)
- {
- }
-
- protected virtual void OnItemUpdated (ListViewUpdatedEventArgs e)
- {
- }
-
- protected virtual void OnItemUpdating (ListViewUpdateEventArgs e)
- {
- }
-
- protected virtual void OnLayoutCreated (EventArgs e)
- {
- }
-
- protected virtual void OnPagePropertiesChanged (EventArgs e)
- {
- }
-
- protected virtual void OnPagePropertiesChanging (PagePropertiesChangingEventArgs e)
- {
- }
-
- protected virtual void OnSelectedIndexChanged (EventArgs e)
- {
- }
-
- protected virtual void OnSelectedIndexChanging (ListViewSelectEventArgs e)
- {
- }
-
- protected virtual void OnSorted (EventArgs e)
- {
- }
-
- protected virtual void OnSorting (ListViewSortEventArgs e)
- {
- }
-
- protected virtual void OnTotalRowCountAvailable (PageEventArgs e)
- {
- }
-
- protected override void PerformDataBinding (IEnumerable data)
- {
- base.PerformDataBinding (data);
- TrackViewState ();
- int childCount = CreateChildControls (data, true);
- ChildControlsCreated = true;
- }
-
- protected override void PerformSelect ()
- {
- EnsureLayoutTemplate ();
- base.PerformSelect ();
- }
-
- protected virtual void RemoveItems ()
- {
- }
-
- protected override void Render (HtmlTextWriter writer)
- {
- base.Render (writer);
- }
-
- protected override object SaveControlState ()
- {
- throw new NotImplementedException ();
- }
-
- protected override object SaveViewState ()
- {
- object[] states = new object [2];
- states [0] = base.SaveViewState ();
- states [1] = null;
- return states;
- }
-
- protected virtual void SetPageProperties (int startRowIndex, int maximumRows, bool databind)
- {
- }
-
- public virtual void Sort (string sortExpression, SortDirection sortDirection)
- {
- }
-
- void IPageableItemContainer.SetPageProperties (int startRowIndex, int maximumRows, bool databind)
- {
- throw new NotImplementedException ();
- }
-
- public virtual void UpdateItem (int itemIndex, bool causesValidation)
- {
- }
-
- [DesignerSerializationVisibilityAttribute (DesignerSerializationVisibility.Hidden)]
- [EditorBrowsableAttribute (EditorBrowsableState.Never)]
- [BrowsableAttribute (false)]
- public override string AccessKey {
- get { return base.AccessKey; }
- set { throw StylingNotSupported (); }
- }
-
- [TemplateContainerAttribute (typeof (ListViewDataItem), BindingDirection.TwoWay)]
- [PersistenceModeAttribute (PersistenceMode.InnerProperty)]
- [DefaultValueAttribute (null)]
- [BrowsableAttribute (false)]
- public virtual ITemplate AlternatingItemTemplate {
- get { return _alternatingItemTemplate; }
- set { _alternatingItemTemplate = value; }
- }
-
- [DesignerSerializationVisibilityAttribute (DesignerSerializationVisibility.Hidden)]
- [EditorBrowsableAttribute (EditorBrowsableState.Never)]
- [BrowsableAttribute (false)]
- public override Color BackColor {
- get { return base.BackColor; }
- set { throw StylingNotSupported (); }
- }
-
- [DesignerSerializationVisibilityAttribute (DesignerSerializationVisibility.Hidden)]
- [BrowsableAttribute (false)]
- [EditorBrowsableAttribute (EditorBrowsableState.Never)]
- public override Color BorderColor {
- get { return base.BorderColor; }
- set { throw StylingNotSupported (); }
- }
-
- [DesignerSerializationVisibilityAttribute (DesignerSerializationVisibility.Hidden)]
- [EditorBrowsableAttribute (EditorBrowsableState.Never)]
- [BrowsableAttribute (false)]
- public override BorderStyle BorderStyle {
- get { return base.BorderStyle; }
- set { throw StylingNotSupported (); }
- }
-
- [BrowsableAttribute (false)]
- [EditorBrowsableAttribute (EditorBrowsableState.Never)]
- [DesignerSerializationVisibilityAttribute (DesignerSerializationVisibility.Hidden)]
- public override Unit BorderWidth {
- get { return base.BorderWidth; }
- set { throw StylingNotSupported (); }
- }
-
- public override ControlCollection Controls {
- get {
- EnsureChildControls ();
- return base.Controls;
- }
- }
-
- [CategoryAttribute ("Behavior")]
- [DefaultValueAttribute (true)]
- public virtual bool ConvertEmptyStringToNull {
- get {
- object o = ViewState ["ConvertEmptyStringToNull"];
- if (o != null)
- return (bool) o;
- return true;
- }
-
- set { ViewState ["ConvertEmptyStringToNull"] = value; }
- }
-
- public override string CssClass {
- get { return base.CssClass; }
- set { throw StylingNotSupported (); }
- }
-
- [DefaultValueAttribute (null)]
- [TypeConverterAttribute (typeof (StringArrayConverter))]
- [CategoryAttribute ("Data")]
- public virtual string [] DataKeyNames {
- get {
- if (_dataKeyNames != null)
- return _dataKeyNames;
- return new string [0];
- }
- set {
- if (value == null)
- _dataKeyNames = null;
- else
- _dataKeyNames = (string []) value.Clone ();
- // They will eventually be recreated when data binding
- _dataKeyArray = null;
- _dataKeys = null;
-
- if (Initialized)
- RequiresDataBinding = true;
- }
- }
-
- [BrowsableAttribute (false)]
- [DesignerSerializationVisibilityAttribute (DesignerSerializationVisibility.Hidden)]
- public virtual DataKeyArray DataKeys {
- get {
- if (_dataKeys == null) {
- _dataKeys = new DataKeyArray (DataKeyArray);
- if (IsTrackingViewState)
- ((IStateManager) _dataKeys).TrackViewState ();
- }
- return _dataKeys;
- }
- }
- ArrayList DataKeyArray {
- get {
- if (_dataKeyArray == null)
- _dataKeyArray = new ArrayList ();
- return _dataKeyArray;
- }
- }
-
- [DefaultValueAttribute (-1)]
- [CategoryAttribute ("Misc")]
- public virtual int EditIndex {
- get { return _editIndex; }
- set {
- if (value < -1)
- throw new ArgumentOutOfRangeException ("value");
- if (value != _editIndex) {
- _editIndex = value;
- if (Initialized)
- RequiresDataBinding = true;
- }
- }
- }
-
- [BrowsableAttribute (false)]
- [DesignerSerializationVisibilityAttribute (DesignerSerializationVisibility.Hidden)]
- public virtual ListViewItem EditItem {
- get { throw new NotImplementedException (); }
- }
-
- [DefaultValueAttribute (null)]
- [BrowsableAttribute (false)]
- [TemplateContainerAttribute (typeof (ListViewDataItem), BindingDirection.TwoWay)]
- [PersistenceModeAttribute (PersistenceMode.InnerProperty)]
- public virtual ITemplate EditItemTemplate {
- get { return _editItemTemplate; }
- set { _editItemTemplate = value; }
- }
-
- [DefaultValueAttribute (null)]
- [TemplateContainerAttribute (typeof (ListView))]
- [PersistenceModeAttribute (PersistenceMode.InnerProperty)]
- [BrowsableAttribute (false)]
- public virtual ITemplate EmptyDataTemplate {
- get { return _emptyDataTemplate; }
- set { _emptyDataTemplate = value; }
- }
-
- [TemplateContainerAttribute (typeof (ListViewItem))]
- [DefaultValueAttribute (null)]
- [PersistenceModeAttribute (PersistenceMode.InnerProperty)]
- [BrowsableAttribute (false)]
- public virtual ITemplate EmptyItemTemplate {
- get { return _emptyItemTemplate; }
- set { _emptyItemTemplate = value; }
- }
-
- [BrowsableAttribute (false)]
- [EditorBrowsableAttribute (EditorBrowsableState.Never)]
- [DesignerSerializationVisibilityAttribute (DesignerSerializationVisibility.Hidden)]
- public override FontInfo Font {
- get { throw StylingNotSupported (); }
- }
-
- [DesignerSerializationVisibilityAttribute (DesignerSerializationVisibility.Hidden)]
- [EditorBrowsableAttribute (EditorBrowsableState.Never)]
- [BrowsableAttribute (false)]
- public override Color ForeColor {
- get { return base.ForeColor; }
- set { throw StylingNotSupported (); }
- }
-
- [CategoryAttribute ("Misc")]
- [DefaultValueAttribute (1)]
- public virtual int GroupItemCount {
- get { return _groupItemCount; }
- set {
- if (value < 1)
- throw new ArgumentOutOfRangeException ("value");
- if (value != _groupItemCount) {
- _groupItemCount = value;
- if (Initialized)
- RequiresDataBinding = true;
- }
- }
- }
-
- [CategoryAttribute ("Behavior")]
- [DefaultValueAttribute ("groupPlaceholder")]
- public virtual string GroupPlaceholderID {
- get {
- string s = ViewState ["GroupPlaceholderID"] as string;
- if (s != null)
- return s;
- return "groupPlaceHolder";
- }
-
- set {
- if (String.IsNullOrEmpty (value))
- throw new ArgumentOutOfRangeException ("value");
- ViewState ["GroupPlaceholderID"] = value;
- }
- }
-
- [BrowsableAttribute (false)]
- [PersistenceModeAttribute (PersistenceMode.InnerProperty)]
- [DefaultValueAttribute (null)]
- [TemplateContainerAttribute (typeof (ListViewItem))]
- public virtual ITemplate GroupSeparatorTemplate {
- get { return _groupSeparatorTemplate; }
- set { _groupSeparatorTemplate = value; }
- }
-
- [TemplateContainerAttribute (typeof (ListViewItem))]
- [DefaultValueAttribute (null)]
- [BrowsableAttribute (false)]
- [PersistenceModeAttribute (PersistenceMode.InnerProperty)]
- public virtual ITemplate GroupTemplate {
- get { return _groupTemplate; }
- set { _groupTemplate = value; }
- }
-
- [EditorBrowsableAttribute (EditorBrowsableState.Never)]
- [BrowsableAttribute (false)]
- [DesignerSerializationVisibilityAttribute (DesignerSerializationVisibility.Hidden)]
- public override Unit Height {
- get { return base.Height; }
- set { throw StylingNotSupported (); }
- }
-
- [DesignerSerializationVisibilityAttribute (DesignerSerializationVisibility.Hidden)]
- [BrowsableAttribute (false)]
- public virtual ListViewItem InsertItem {
- get;
- private set;
- }
-
- [CategoryAttribute ("Misc")]
- [DefaultValueAttribute (InsertItemPosition.None)]
- public virtual InsertItemPosition InsertItemPosition {
- get;
- set;
- }
-
- [TemplateContainerAttribute (typeof (ListViewItem), BindingDirection.TwoWay)]
- [PersistenceModeAttribute (PersistenceMode.InnerProperty)]
- [DefaultValueAttribute (null)]
- [BrowsableAttribute (false)]
- public virtual ITemplate InsertItemTemplate {
- get { return _insertItemTemplate; }
- set { _insertItemTemplate = value; }
- }
-
- [DefaultValueAttribute ("itemPlaceholder")]
- [CategoryAttribute ("Behavior")]
- public virtual string ItemPlaceholderID {
- get {
- string s = ViewState ["ItemPlaceHolderID"] as string;
- if (s != null)
- return s;
- return "itemPlaceholder";
- }
-
- set {
- if (String.IsNullOrEmpty (value))
- throw new ArgumentOutOfRangeException ("value");
-
- ViewState ["ItemPlaceHolderID"] = value;
- }
- }
-
- [DesignerSerializationVisibilityAttribute (DesignerSerializationVisibility.Hidden)]
- [BrowsableAttribute (false)]
- public virtual IList <ListViewDataItem> Items {
- get { throw new NotImplementedException (); }
- }
-
- [PersistenceModeAttribute (PersistenceMode.InnerProperty)]
- [BrowsableAttribute (false)]
- [TemplateContainerAttribute (typeof (ListViewItem))]
- [DefaultValueAttribute (null)]
- public virtual ITemplate ItemSeparatorTemplate {
- get { return _itemSeparatorTemplate; }
- set { _itemSeparatorTemplate = value; }
- }
-
- [TemplateContainerAttribute (typeof (ListViewDataItem), BindingDirection.TwoWay)]
- [DefaultValueAttribute (null)]
- [PersistenceModeAttribute (PersistenceMode.InnerProperty)]
- [BrowsableAttribute (false)]
- public virtual ITemplate ItemTemplate {
- get { return _itemTemplate; }
- set { _itemTemplate = value; }
- }
-
- [TemplateContainerAttribute (typeof (ListView))]
- [PersistenceModeAttribute (PersistenceMode.InnerProperty)]
- [DefaultValueAttribute (null)]
- [BrowsableAttribute (false)]
- public virtual ITemplate LayoutTemplate {
- get { return _layoutTemplate; }
- set { _layoutTemplate = value; }
- }
-
- protected virtual int MaximumRows {
- get { return _maximumRows; }
- }
-
- [BrowsableAttribute (false)]
- [DesignerSerializationVisibilityAttribute (DesignerSerializationVisibility.Hidden)]
- public virtual DataKey SelectedDataKey {
- get {
- if (_dataKeyNames == null || _dataKeyNames.Length == 0)
- throw new InvalidOperationException ("No data keys are specified in the DataKeyNames property.");
- DataKeyArray dataKeys = DataKeys;
- int selIndex = SelectedIndex;
- if (selIndex > -1 || selIndex < dataKeys.Count)
- return dataKeys [selIndex];
- return null;
- }
- }
-
- [CategoryAttribute ("Misc")]
- [DefaultValueAttribute (-1)]
- public virtual int SelectedIndex {
- get { return _selectedIndex; }
- set {
- if (value < -1)
- throw new ArgumentOutOfRangeException ("value");
- if (value != _selectedIndex) {
- _selectedIndex = value;
- if (Initialized)
- RequiresDataBinding = true;
- }
- }
- }
-
- [BrowsableAttribute (false)]
- [DefaultValueAttribute (null)]
- [PersistenceModeAttribute (PersistenceMode.InnerProperty)]
- [TemplateContainerAttribute (typeof (ListViewDataItem), BindingDirection.TwoWay)]
- public virtual ITemplate SelectedItemTemplate {
- get { return _selectedItemTemplate; }
- set { _selectedItemTemplate = value; }
- }
-
- [DesignerSerializationVisibilityAttribute (DesignerSerializationVisibility.Hidden)]
- [BrowsableAttribute (false)]
- public object SelectedValue {
- get {
- DataKey dk = SelectedDataKey;
- if (dk != null)
- return dk.Value;
- return null;
- }
- }
-
- [DefaultValueAttribute (SortDirection.Ascending)]
- [BrowsableAttribute (false)]
- [PersistenceModeAttribute (PersistenceMode.InnerProperty)]
- [DesignerSerializationVisibilityAttribute (DesignerSerializationVisibility.Hidden)]
- public virtual SortDirection SortDirection {
- get { return _sortDirection; }
- }
-
- [BrowsableAttribute (false)]
- [DesignerSerializationVisibilityAttribute (DesignerSerializationVisibility.Hidden)]
- public virtual string SortExpression {
- get { return _sortExpression; }
- }
-
- protected virtual int StartRowIndex {
- get { return _startRowIndex; }
- }
-
- int IPageableItemContainer.MaximumRows {
- get { return _maximumRows; }
- }
-
- int IPageableItemContainer.StartRowIndex {
- get { return _startRowIndex; }
- }
-
- [EditorBrowsableAttribute (EditorBrowsableState.Never)]
- [BrowsableAttribute (false)]
- [DesignerSerializationVisibilityAttribute (DesignerSerializationVisibility.Hidden)]
- public override short TabIndex {
- get { return 0; }
- set { throw new NotSupportedException ("ListView does not allow setting this property."); }
- }
-
- [EditorBrowsableAttribute (EditorBrowsableState.Never)]
- [BrowsableAttribute (false)]
- [DesignerSerializationVisibilityAttribute (DesignerSerializationVisibility.Hidden)]
- public override string ToolTip {
- get { return base.ToolTip; }
- set { throw StylingNotSupported (); }
- }
-
- [EditorBrowsableAttribute (EditorBrowsableState.Never)]
- [DesignerSerializationVisibilityAttribute (DesignerSerializationVisibility.Hidden)]
- [BrowsableAttribute (false)]
- public override Unit Width {
- get { return base.Width; }
- set { throw StylingNotSupported (); }
- }
-
- [CategoryAttribute ("Action")]
- public event EventHandler <ListViewCancelEventArgs> ItemCanceling;
-
- [CategoryAttribute ("Action")]
- public event EventHandler <ListViewCommandEventArgs> ItemCommand;
-
- [CategoryAttribute ("Behavior")]
- public event EventHandler <ListViewItemEventArgs> ItemCreated;
-
- [CategoryAttribute ("Data")]
- public event EventHandler <ListViewItemEventArgs> ItemDataBound;
-
- [CategoryAttribute ("Action")]
- public event EventHandler <ListViewDeletedEventArgs> ItemDeleted;
-
- [CategoryAttribute ("Action")]
- public event EventHandler <ListViewDeleteEventArgs> ItemDeleting;
-
- [CategoryAttribute ("Action")]
- public event EventHandler <ListViewEditEventArgs> ItemEditing;
-
- [CategoryAttribute ("Action")]
- public event EventHandler <ListViewInsertedEventArgs> ItemInserted;
-
- [CategoryAttribute ("Action")]
- public event EventHandler <ListViewInsertEventArgs> ItemInserting;
-
- [CategoryAttribute ("Action")]
- public event EventHandler <ListViewUpdatedEventArgs> ItemUpdated;
-
- [CategoryAttribute ("Action")]
- public event EventHandler <ListViewUpdateEventArgs> ItemUpdating;
-
- [CategoryAttribute ("Behavior")]
- public event EventHandler LayoutCreated;
-
- [CategoryAttribute ("Behavior")]
- public event EventHandler PagePropertiesChanged;
-
- [CategoryAttribute ("Behavior")]
- public event EventHandler <PagePropertiesChangingEventArgs> PagePropertiesChanging;
-
- [CategoryAttribute ("Action")]
- public event EventHandler SelectedIndexChanged;
-
- [CategoryAttribute ("Action")]
- public event EventHandler <ListViewSelectEventArgs> SelectedIndexChanging;
-
- [CategoryAttribute ("Action")]
- public event EventHandler Sorted;
-
- [CategoryAttribute ("Action")]
- public event EventHandler <ListViewSortEventArgs> Sorting;
-
- event EventHandler <PageEventArgs> IPageableItemContainer.TotalRowCountAvailable {
- add {
- }
- remove {
- }
- }
- NotSupportedException StylingNotSupported ()
- {
- return new NotSupportedException ("Style properties are not supported on ListView. Apply styling or CSS classes to the elements in the ListView's templates.");
- }
- }
- }
- #endif
|