Exemplo n.º 1
0
		private int RenderDataItems(HtmlTextWriter writer, int index)
		{
			if(this.DataSource == null)
				return index;

			var dataSource = this.DataSource as IEnumerable;

			if(dataSource == null)
			{
				var item = new ComboBoxItem()
				{
					Value = BindingUtility.FormatBindingValue(_binding != null ? _binding.ValueMember : string.Empty, this.DataSource, true),
					Text = BindingUtility.FormatBindingValue(_binding != null ? _binding.TextMember : string.Empty, this.DataSource, true),
					Description = BindingUtility.FormatBindingValue(_binding != null ? _binding.DescriptionMember : string.Empty, this.DataSource, true),
					Icon = BindingUtility.FormatBindingValue(_binding != null ? _binding.IconMember : string.Empty, this.DataSource, true),
				};

				var isSelected = this.IsSelected(index, item.Value);

				if(isSelected)
					_selectedItem = item;

				if(_itemTemplate == null)
					item.ToHtmlString(writer, this.RenderMode, isSelected);
				else
					this.RenderItemTemplate(writer, item.Value, this.DataSource, index, isSelected);
			}
			else
			{
				foreach(object dataItem in dataSource)
				{
					var item = new ComboBoxItem()
					{
						Value = BindingUtility.FormatBindingValue(_binding != null ? _binding.ValueMember : string.Empty, dataItem, true),
						Text = BindingUtility.FormatBindingValue(_binding != null ? _binding.TextMember : string.Empty, dataItem, true),
						Description = BindingUtility.FormatBindingValue(_binding != null ? _binding.DescriptionMember : string.Empty, dataItem, true),
						Icon = BindingUtility.FormatBindingValue(_binding != null ? _binding.IconMember : string.Empty, dataItem, true),
					};

					var isSelected = this.IsSelected(index, item.Value);

					if(isSelected)
						_selectedItem = item;

					if(_itemTemplate == null)
						item.ToHtmlString(writer, this.RenderMode, isSelected);
					else
						this.RenderItemTemplate(writer, item.Value, dataItem, index, isSelected);
				}
			}

			return ++index;
		}
Exemplo n.º 2
0
		private int RenderItems(HtmlTextWriter writer, int index)
		{
			foreach(var item in _items)
			{
				var isSelected = this.IsSelected(index, item.Value);

				if(isSelected)
					_selectedItem = item;

				//if(_itemTemplate == null)
					item.ToHtmlString(writer, this.RenderMode, isSelected);
				//else
				//	this.RenderItemTemplate(writer, item.Value, item, index);

				index++;
			}

			return index;
		}