示例#1
0
        /// <summary>
        /// 加载ClientState
        /// </summary>
        /// <param name="clientState">序列化后的clientState</param>
        /// <remarks>加载ClientState</remarks>
        protected override void LoadClientState(string clientState)
        {
            base.LoadClientState(clientState);

            object[] foArray = JSONSerializerExecute.Deserialize <object[]>(clientState);

            if (foArray != null && foArray.Length > 0)
            {
                //已选择列表的Items
                if (foArray[0] != null && foArray.Length > 0)
                {
                    this.selectedItems = (SelectItemCollection)JSONSerializerExecute.DeserializeObject(foArray[0], typeof(SelectItemCollection));
                }
                //待选择列表的Items
                if (foArray[1] != null && foArray.Length > 1)
                {
                    this.candidateItems = (SelectItemCollection)JSONSerializerExecute.DeserializeObject(foArray[1], typeof(SelectItemCollection));
                }
                //按钮的Items
                if (foArray[2] != null && foArray.Length > 2)
                {
                    this.buttonItems = (ButtonItemCollection)JSONSerializerExecute.DeserializeObject(foArray[2], typeof(ButtonItemCollection));
                }

                //deltaItems
                if (foArray[3] != null && foArray.Length > 3)
                {
                    this.deltaItems = (DeltaItemCollection)JSONSerializerExecute.DeserializeObject(foArray[3], typeof(DeltaItemCollection));
                }
            }
        }
示例#2
0
        /// <summary>
        /// 绑定数据源
        /// </summary>
        /// <param name="dataSource">数据源</param>
        /// <remarks>如果给控件设置了数据源,此方法是将数据源的数据绑定到待选择列表数据集合</remarks>
        protected override void PerformDataBinding(IEnumerable dataSource)
        {
            if (dataSource != null)
            {
                if (this.candidateItems == null)
                {
                    //如果数据集合为null,则实例化
                    this.candidateItems = new SelectItemCollection();
                }
                //Field是否为空标记
                bool   flag           = false;
                string propName       = this.DataSourseTextField;
                string dataValueField = this.DataSourseValueField;
                string dataSortField  = this.DataSourseSortField;

                ICollection iData = dataSource as ICollection;

                if ((propName.Length != 0) || (dataValueField.Length != 0) || dataSortField.Length != 0)
                {
                    flag = true;
                }
                //取出dataSourse
                foreach (object objData in dataSource)
                {
                    SelectItem item = new SelectItem();
                    if (flag)
                    {
                        if (propName.Length > 0)
                        {
                            item.SelectListBoxText = DataBinder.GetPropertyValue(objData, propName, null);
                        }
                        if (dataValueField.Length > 0)
                        {
                            item.SelectListBoxValue = DataBinder.GetPropertyValue(objData, dataValueField, null);
                        }
                        if (dataSortField.Length > 0)
                        {
                            item.SelectListBoxSortColumn = DataBinder.GetPropertyValue(objData, dataSortField, null);
                        }
                    }
                    else
                    {
                        item.SelectListBoxText       = objData.ToString();
                        item.SelectListBoxValue      = objData.ToString();
                        item.SelectListBoxSortColumn = objData.ToString();
                    }
                    this.candidateItems.Add(item);
                }
            }
        }
示例#3
0
		/// <summary>
		/// 加载ClientState
		/// </summary>
		/// <param name="clientState">序列化后的clientState</param>
		/// <remarks>加载ClientState</remarks>
		protected override void LoadClientState(string clientState)
		{
			base.LoadClientState(clientState);

			object[] foArray = JSONSerializerExecute.Deserialize<object[]>(clientState);

			if (foArray != null && foArray.Length > 0)
			{
				//已选择列表的Items
				if (foArray[0] != null && foArray.Length > 0)
				{
					this.selectedItems = (SelectItemCollection)JSONSerializerExecute.DeserializeObject(foArray[0], typeof(SelectItemCollection));
				}
				//待选择列表的Items
				if (foArray[1] != null && foArray.Length > 1)
				{
					this.candidateItems = (SelectItemCollection)JSONSerializerExecute.DeserializeObject(foArray[1], typeof(SelectItemCollection));
				}
				//按钮的Items
				if (foArray[2] != null && foArray.Length > 2)
				{
					this.buttonItems = (ButtonItemCollection)JSONSerializerExecute.DeserializeObject(foArray[2], typeof(ButtonItemCollection));
				}

				//deltaItems
				if (foArray[3] != null && foArray.Length > 3)
				{
					this.deltaItems = (DeltaItemCollection)JSONSerializerExecute.DeserializeObject(foArray[3], typeof(DeltaItemCollection));
				}
			}

		}
示例#4
0
		/// <summary>
		/// 绑定数据源
		/// </summary>
		/// <param name="dataSource">数据源</param>
		/// <remarks>如果给控件设置了数据源,此方法是将数据源的数据绑定到待选择列表数据集合</remarks>
		protected override void PerformDataBinding(IEnumerable dataSource)
		{
			if (dataSource != null)
			{
				if (this.candidateItems == null)
				{
					//如果数据集合为null,则实例化
					this.candidateItems = new SelectItemCollection();
				}
				//Field是否为空标记
				bool flag = false;
				string propName = this.DataSourseTextField;
				string dataValueField = this.DataSourseValueField;
				string dataSortField = this.DataSourseSortField;

				ICollection iData = dataSource as ICollection;

				if ((propName.Length != 0) || (dataValueField.Length != 0) || dataSortField.Length != 0)
				{
					flag = true;
				}
				//取出dataSourse
				foreach (object objData in dataSource)
				{
					SelectItem item = new SelectItem();
					if (flag)
					{
						if (propName.Length > 0)
						{
							item.SelectListBoxText = DataBinder.GetPropertyValue(objData, propName, null);
						}
						if (dataValueField.Length > 0)
						{
							item.SelectListBoxValue = DataBinder.GetPropertyValue(objData, dataValueField, null);
						}
						if (dataSortField.Length > 0)
						{
							item.SelectListBoxSortColumn = DataBinder.GetPropertyValue(objData, dataSortField, null);
						}
					}
					else
					{
						item.SelectListBoxText = objData.ToString();
						item.SelectListBoxValue = objData.ToString();
						item.SelectListBoxSortColumn = objData.ToString();
					}
					this.candidateItems.Add(item);
				}
			}
		}