HtmlInputCheckBox checkBox = new HtmlInputCheckBox(); checkBox.ID = "myCheckBox"; checkBox.Value = "checkValue"; checkBox.Checked = true;
foreach (var item in itemList) { HtmlInputCheckBox checkBox = new HtmlInputCheckBox(); checkBox.ID = "checkBox_" + item.Id; checkBox.Value = item.Name; checkBox.Checked = item.IsSelected; // Add the checkbox to a container element checkboxContainer.Controls.Add(checkBox); }In this example, we created a checkbox for each item in a list of items. The ID of each checkbox is unique, and includes the ID of the item it represents. The value of each checkbox is the name of the item. The isChecked property is determined by whether the item is already selected or not. Finally, we add each checkbox to a container element on the page. The library for this control is included in the .NET Framework, specifically in the System.Web.UI.HtmlControls namespace.