New to Telerik UI for ASP.NET AJAX? Start a free 30-day trial
SelectionChanged
The SelectionChanged event occurs when the selection of RadMultiSelect is changed by the user, after the the ItemSelected and ItemDeselected events are triggered.
The SelectionChanged event does not fire unless the AutoPostBack property is set to True or a PostBack on the page occurs.
The SelectionChanged event handler receives one argument:
-
The RadMultiSelect instance that is loading items. This argument is of type object, but can be cast to the RadMultiSelect type.
-
An empty EventArgs object.
Use the SelectionChanged event handler to respond in server-side code when the user selects/deselects RadMultiselect item(s):
ASP.NET
<telerik:RadMultiSelect ID="RadMultiSelect1" runat="server" DataTextField="text" DataValueField="value" Filter="Contains" AutoPostBack="true" OnSelectionChanged="RadMultiSelect1_SelectionChanged">
<Items>
<telerik:MultiSelectItem Text="Steven White" Value="1"></telerik:MultiSelectItem>
<telerik:MultiSelectItem Text="Nancy King" Value="2"></telerik:MultiSelectItem>
<telerik:MultiSelectItem Text="Nancy Davolio" Value="3"></telerik:MultiSelectItem>
<telerik:MultiSelectItem Text="Robert Davolio" Value="4"></telerik:MultiSelectItem>
<telerik:MultiSelectItem Text="Michael Leverling" Value="5"></telerik:MultiSelectItem>
</Items>
</telerik:RadMultiSelect>
C#
protected void RadMultiSelect1_SelectionChanged(object sender, EventArgs e)
{
var selectedValues = RadMultiSelect1.Value;
foreach (string value in selectedValues)
{
MultiSelectItem selectedItem = RadMultiSelect1.Items.FindChildByValue(value);
string result = string.Format("Selected item with text: <strong>{0}</strong> and value: <strong>{1}</strong><br />", selectedItem.Text, selectedItem.Value);
Response.Write(result);
}
}