System.Web.UI.WebControls.CheckBoxList.RenderItem C# (CSharp) Method

RenderItem() protected method

protected RenderItem ( ListItemType itemType, int repeatIndex, RepeatInfo repeatInfo, System.Web.UI.HtmlTextWriter writer ) : void
itemType ListItemType
repeatIndex int
repeatInfo RepeatInfo
writer System.Web.UI.HtmlTextWriter
return void
		void RenderItem (ListItemType itemType,
				 int repeatIndex,
				 RepeatInfo repeatInfo,
				 HtmlTextWriter writer)
		{
			ListItem item = Items [repeatIndex];

			check_box.ID = repeatIndex.ToString (Helpers.InvariantCulture);
			check_box.Text = item.Text;
			check_box.AutoPostBack = AutoPostBack;
			check_box.Checked = item.Selected;
			check_box.TextAlign = TextAlign;
#if NET_2_0
			if (!IsEnabled)
				check_box.Enabled = false;
			else
				check_box.Enabled = item.Enabled;

			check_box.ValidationGroup = ValidationGroup;
			check_box.CausesValidation = CausesValidation;
			if (check_box.HasAttributes)
				check_box.Attributes.Clear ();
			if (item.HasAttributes)
				check_box.Attributes.CopyFrom (item.Attributes);
#else
			check_box.Enabled = Enabled;
#endif
			check_box.RenderControl (writer);
		}

Usage Example

		public void RepeatInfoRenderOutOfRange ()
		{
			StringWriter sw = new StringWriter ();
			HtmlTextWriter tw = new HtmlTextWriter (sw);
			IRepeatInfoUser ri = new CheckBoxList ();

			ri.RenderItem (ListItemType.Item, -1, new RepeatInfo (), tw); 
		}