# Create Checkbox Custom Item Templates in the MultiSelect

## Environment

<table>
	<tr>
  		<td>Product</td>
  		<td>Telerik UI for ASP.NET MVC MultiSelect</td>
 	</tr>
 	<tr>
		<td>Product Version</td>
		<td>2024.3.806</td>
	</tr>
</table>

## Description

How can I create a Telerik UI for ASP.NET MVC MultiSelect with checkboxes for each of the constructed items within the items list?

## Solution

1. Use the [`ItemTemplate()`](https://www.telerik.com/aspnet-mvc/documentation/api/kendo.mvc.ui.fluent/multiselectbuilder#itemtemplatesystemstring) API configuration to add an input field to each item in the MultiSelect.
2. Subscribe to the [`Change()`](https://www.telerik.com/aspnet-mvc/documentation/api/kendo.mvc.ui.fluent/multiselecteventbuilder#changesystemstring) and [`DataBound()`](https://www.telerik.com/aspnet-mvc/documentation/api/kendo.mvc.ui.fluent/multiselecteventbuilder#databoundsystemstring) events to manage the functionality for the checkboxes.
3. Include JavaScript code to control the toggle of the [`'checked'`](https://api.jquery.com/prop/) property of the newly created checkboxes.

```Razor HtmlHelper
	@(Html.Kendo().MultiSelect()
		.Name("movies")
		.ItemTemplate("<input class='k-checkbox' type='checkbox' /><span>#: data.Text #</span>")
		.DataTextField("Text")
		.DataValueField("Value")
		.AutoClose(false)
		.DownArrow()
		.Placeholder("Select movie...")
		.Events(e => e.Change("onChange").DataBound("onDataBound"))
		.Value("1")
		.BindTo(new List<SelectListItem>()
		{
			new SelectListItem() {
			Text = "12 Angry Men", Value ="1"
			},
			new SelectListItem() {
			Text = "Il buono, il brutto, il cattivo.", Value ="2"
			},
			new SelectListItem() {
			Text = "Inception", Value ="3"
			},
			new SelectListItem() {
			Text = "One Flew Over the Cuckoo's Nest", Value ="4"
			},
			new SelectListItem() {
			Text = "Pulp Fiction", Value ="5"
			},
			new SelectListItem() {
			Text = "Schindler's List", Value ="6"
			},
			new SelectListItem() {
			Text = "The Dark Knight", Value ="7"
			},
			new SelectListItem() {
			Text = "The Godfather", Value ="8"
			},
			new SelectListItem() {
			Text = "The Godfather: Part II", Value ="9"
			},
			new SelectListItem() {
			Text = "The Shawshank Redemption", Value ="10"
			},
			new SelectListItem() {
			Text = "The Shawshank Redemption 2", Value ="11"
			}
		})
	)
```

```JS script.js
	<script>
		function checkInputs(elements) { // Toggle 'checked' property, based on the selected items.
			elements.each(function() {
				var element = $(this);
				var input = element.find("input");
				input.prop("checked", element.hasClass("k-selected"));
			});
		};
		function onDataBound(e){ // Triggers the checked action for pre defined selections.
			var items = this.ul.find("li");
			setTimeout(function() {
				checkInputs(items);
			});
		}
		function onChange(e) { // Listens for changes over the component.
			var items = this.ul.find("li");
				checkInputs(items);
		}
	</script>
```

For a runnable example based on the code above, refer to the [REPL example on Create Checkbox Custom Item Templates in the MultiSelect](https://netcorerepl.telerik.com/mSPEkobb20oEc5KA55).

## More ASP.NET MVC MultiSelect Resources

* [ASP.NET MVC MultiSelect Item Template](https://docs.telerik.com/aspnet-mvc/html-helpers/editors/multiselect/templates#item-template)

* [ASP.NET MVC MultiSelect Documentation](https://www.telerik.com/aspnet-mvc/documentation/html-helpers/editors/multiselect/overview)

* [ASP.NET MVC MultiSelect Demos](https://demos.telerik.com/aspnet-mvc/multiselect)

* [ASP.NET MVC MultiSelect Product Page](https://www.telerik.com/aspnet-mvc/multiselect)

* [Telerik UI for ASP.NET MVC Video Onboarding Course (Free for trial users and license holders)](https://www.telerik.com/aspnet-mvc/documentation/getting-started/video-onboarding)

* [Telerik UI for ASP.NET MVC Forums](https://www.telerik.com/forums/aspnet-mvc)

## See Also

* [Client-Side API Reference of the MultiSelect for ASP.NET MVC](https://docs.telerik.com/kendo-ui/api/ui/multiselect)
* [Server-Side API Reference of the MultiSelect for ASP.NET MVC](https://docs.telerik.com/aspnet-mvc/api/multiselect)
* [Telerik UI for ASP.NET MVC Breaking Changes](https://docs.telerik.com/aspnet-mvc/backwards-compatibility/overview)
* [Telerik UI for ASP.NET MVC Knowledge Base](https://docs.telerik.com/aspnet-mvc/knowledge-base)
