Example #1
0
        /// <summary>
        /// LoadPostData
        /// </summary>
        /// <param name="postDataKey"></param>
        /// <param name="postCollection"></param>
        /// <returns>bool</returns>
        public bool LoadPostData(string postDataKey, NameValueCollection postCollection)
        {
            if (base.IsEnabled)
            {
                if (!String.IsNullOrEmpty(postDataKey))
                {
                    if (postDataKey.Contains(this.UniqueID))
                    {
                        if (postCollection != null)
                        {
                            foreach (string key in postCollection.Keys)
                            {
                                if (key.Contains(this.UniqueID))
                                {
                                    // the checkbox's UniqueID property is something like:
                                    //     ctl00_PlaceHolderMain_chkListLearners_20
                                    // this code parses out the "20"
                                    string text1 = key.Substring(this.UniqueID.Length + 1);

                                    int num1 = int.Parse(text1, CultureInfo.InvariantCulture);
                                    this.EnsureDataBound();

                                    SlkCheckBoxItem item
                                        = this.Items.FindByValue(num1.ToString(CultureInfo.InvariantCulture));

                                    bool flag = postCollection[key] != null;

                                    if (item.Selected != flag)
                                    {
                                        item.Selected = flag;
                                    }
                                }
                            }
                        }
                    }
                }
            }
            return(false);
        }
Example #2
0
        /// <summary>
        /// Performs Data Binding operation for ControlToRepeat
        /// </summary>
        /// <param name="data">Datasource Collection to be binded</param>
        protected override void PerformDataBinding(IEnumerable data)
        {
            base.PerformDataBinding(data);

            string textField    = DataTextField;
            string valueField   = DataValueField;
            string stateField   = DataStateField;
            string toolTipField = DataToolTipField;

            if (data != null)
            {
                foreach (object o in data)
                {
                    SlkCheckBoxItem item
                                  = new SlkCheckBoxItem();
                    item.Text     = DataBinder.GetPropertyValue(o, textField, null);
                    item.Value    = DataBinder.GetPropertyValue(o, valueField, null);
                    item.Selected = bool.Parse(DataBinder.GetPropertyValue(o, stateField, null));
                    item.ToolTip  = DataBinder.GetPropertyValue(o, toolTipField, null);

                    Items.Add(item);
                }
            }
        }