private CheckItem CreateCheckItem(Object obj) { CheckItem item = new CheckItem(); if (obj is string) { item.Text = obj.ToString(); item.Value = obj.ToString(); } else { if (!String.IsNullOrEmpty(DataTextField)) { if (!String.IsNullOrEmpty(DataTextFormatString)) { item.Text = String.Format(DataTextFormatString, GetPropertyValue(obj, DataTextField)); } else { item.Text = GetPropertyValue(obj, DataTextField); } } else { item.Text = obj.ToString(); } if (!String.IsNullOrEmpty(DataValueField)) { item.Value = GetPropertyValue(obj, DataValueField); } else { item.Value = obj.ToString(); } } return(item); }
/// <summary> /// 处理回发数据 /// </summary> /// <param name="postDataKey">回发数据键</param> /// <param name="postCollection">回发数据集</param> /// <returns>回发数据是否改变</returns> public virtual bool LoadPostData(string postDataKey, System.Collections.Specialized.NameValueCollection postCollection) { //string postValue = postCollection[postDataKey]; List <string> selectedValues = new List <string>(); for (int i = 0, count = Items.Count; i < count; i++) { if (!String.IsNullOrEmpty(postCollection[postDataKey + "_" + i.ToString()])) { CheckItem item = Items[i]; selectedValues.Add(item.Value); } } string[] selectedValueArray = selectedValues.ToArray(); if (!StringUtil.CompareStringArray(selectedValueArray, SelectedValueArray)) { SelectedValueArray = selectedValueArray; XState.BackupPostDataProperty("SelectedValueArray"); return(true); } /* * if (postValue != null && SelectedValue != postValue) * { * CheckItem item = Items.FindByValue(postValue); * if (item != null) * { * SelectedValue = postValue; * XState.BackupPostDataProperty("SelectedValue"); * return true; * } * } */ return(false); }
private CheckItem CreateCheckItem(Object obj) { CheckItem item = new CheckItem(); if (obj is string) { item.Text = obj.ToString(); item.Value = obj.ToString(); } else { if (!String.IsNullOrEmpty(DataTextField)) { if (!String.IsNullOrEmpty(DataTextFormatString)) { item.Text = String.Format(DataTextFormatString, GetPropertyValue(obj, DataTextField)); } else { item.Text = GetPropertyValue(obj, DataTextField); } } else { item.Text = obj.ToString(); } if (!String.IsNullOrEmpty(DataValueField)) { item.Value = GetPropertyValue(obj, DataValueField); } else { item.Value = obj.ToString(); } } return item; }