diff options
Diffstat (limited to 'mcs/class/System.Web/System.Web.UI.WebControls/ListControl.cs')
-rw-r--r-- | mcs/class/System.Web/System.Web.UI.WebControls/ListControl.cs | 105 |
1 files changed, 43 insertions, 62 deletions
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/ListControl.cs b/mcs/class/System.Web/System.Web.UI.WebControls/ListControl.cs index 6da296b7f96..ed86db570cc 100644 --- a/mcs/class/System.Web/System.Web.UI.WebControls/ListControl.cs +++ b/mcs/class/System.Web/System.Web.UI.WebControls/ListControl.cs @@ -115,13 +115,7 @@ namespace System.Web.UI.WebControls { [WebCategory ("Data")] public virtual object DataSource { get { return data_source; } - set { - if(value == null || value is IListSource || value is IEnumerable) { - data_source = value; - return; - } - throw new ArgumentException("Invalid DataSource Type"); - } + set { data_source = value; } } #endif @@ -196,6 +190,10 @@ namespace System.Web.UI.WebControls { return -1; } set { + ClearSelection (); + if (value == -1) + return; + if (items == null || items.Count == 0) { // This will happen when assigning this property // before DataBind () is called on the control. @@ -203,13 +201,8 @@ namespace System.Web.UI.WebControls { return; } - if (value < -1 || value >= Items.Count) + if (value < 0 || value >= Items.Count) throw new ArgumentOutOfRangeException ("value"); - - ClearSelection (); - if (value == -1) - return; - items [value].Selected = true; /* you'd think this would be called, but noooo */ @@ -355,14 +348,40 @@ namespace System.Web.UI.WebControls { if (list == null) return; -#if NET_2_0 - if (!AppendDataBoundItems) -#endif - Items.Clear(); + Items.Clear (); + + string format = DataTextFormatString; + if (format == "") + format = null; + + string text_field = DataTextField; + string value_field = DataValueField; + ListItemCollection coll = Items; + foreach (object container in list) { + string text; + string val; + + text = val = null; + if (text_field != "") { + text = DataBinder.GetPropertyValue (container, text_field, format); + } + + if (value_field != "") { + val = DataBinder.GetPropertyValue (container, value_field).ToString (); + } else if (text_field == "") { + text = val = container.ToString (); + if (format != null) + text = String.Format (format, container); + } else if (text != null) { + val = text; + } + + if (text == null) + text = val; + + coll.Add (new ListItem (text, val)); + } -#if !NET_2_0 - DoDataBinding (list); -#endif if (saved_selected_value != null) { SelectedValue = saved_selected_value; if (saved_selected_index != -2 && saved_selected_index != SelectedIndex) @@ -391,43 +410,6 @@ namespace System.Web.UI.WebControls { base.OnPreRender (e); } - void DoDataBinding (IEnumerable dataSource) - { - if (dataSource != null) { - string format = DataTextFormatString; - if (format == "") - format = null; - - string text_field = DataTextField; - string value_field = DataValueField; - ListItemCollection coll = Items; - foreach (object container in dataSource) { - string text; - string val; - - text = val = null; - if (text_field != "") { - text = DataBinder.GetPropertyValue (container, text_field, format); - } - - if (value_field != "") { - val = DataBinder.GetPropertyValue (container, value_field).ToString (); - } else if (text_field == "") { - text = val = container.ToString (); - if (format != null) - text = String.Format (format, container); - } else if (text != null) { - val = text; - } - - if (text == null) - text = val; - - coll.Add (new ListItem (text, val)); - } - } - } - #if NET_2_0 protected virtual void OnTextChanged (EventArgs e) { @@ -436,17 +418,16 @@ namespace System.Web.UI.WebControls { handler (this, e); } + [MonoTODO] protected internal override void PerformDataBinding (IEnumerable dataSource) { - base.PerformDataBinding (dataSource); - - DoDataBinding (dataSource); + throw new NotImplementedException (); } - [MonoTODO ("why override?")] + [MonoTODO] protected override void PerformSelect () { - base.PerformSelect (); + throw new NotImplementedException (); } [MonoTODO] |