Select2MultiSelect

in namespace DotVVM.Bootstrap5.Select2.Controls

Usage & Scenarios

Extends the Bootstrap 5 MultiSelect control with the Select2 widget, which provides searchable multiple selection.

Install the DotVVM.Controls.Bootstrap5.Select2 package and register it in DotvvmStartup.cs after Bootstrap 5:

config.AddBootstrap5Configuration();
config.AddBootstrap5Select2Configuration();

The control uses the bs prefix and supports all properties of MultiSelect.

Sample 1: Searchable Multiple Selection

Bind SelectedValues to a collection of item values. Users can search for and select multiple options in the Select2 widget.

<bs:Select2MultiSelect SelectedValues="{value: SelectedTechnologies}"
                        DataSource="{value: Technologies}"
                        ItemTextBinding="{value: Name}"
                        ItemValueBinding="{value: Id}" />

<p>Selected technologies: <strong>{{value: SelectedTechnologies}}</strong></p>
using DotVVM.Framework.ViewModel;
using System.Collections.Generic;

namespace DotvvmWeb.Views.Docs.Controls.bootstrap5_select2.Select2MultiSelect.sample1
{
    public class ViewModel : DotvvmViewModelBase
    {
        public List<Technology> Technologies { get; set; } = new List<Technology>
        {
            new Technology { Id = 1, Name = "C#" },
            new Technology { Id = 2, Name = "DotVVM" },
            new Technology { Id = 3, Name = "TypeScript" },
            new Technology { Id = 4, Name = "Bootstrap" }
        };

        public List<int> SelectedTechnologies { get; set; } = new List<int> { 1, 2 };

        public class Technology
        {
            public int Id { get; set; }
            public string Name { get; set; }
        }
    }
}

Properties

Name Type Description Notes Default Value
property icon DataSource Object Gets or sets the source collection or a GridViewDataSet that contains data in the control.
attribute
inner element
static value
bindable
default
null
property icon Enabled Boolean Gets or sets a value indicating whether the control is enabled and can be modified.
attribute
inner element
static value
bindable
default
True
property icon ItemTextBinding IValueBinding<String> The expression of DataSource item that will be displayed in the control.
attribute
inner element
static value
bindable
default
null
property icon ItemTitleBinding IValueBinding The expression of DataSource item that will be placed into html title attribute.
attribute
inner element
static value
bindable
default
null
property icon ItemValueBinding IValueBinding The expression of DataSource item that will be passed to the SelectedValue property when the item is selected.
attribute
inner element
static value
bindable
default
null
property icon SelectedValues Object Gets or sets the values of selected items.
attribute
inner element
static value
bindable
default
null

Events

Name Type Description
event icon SelectionChanged Command Gets or sets the command that will be triggered when the selection is changed.

HTML produced by the control