New to Telerik UI for ASP.NET AJAX? Start a free 30-day trial
Server-side Programming Overview
You can configure the settings of RadMultiSelect and create its elements in the code-behind via the Server-Side API of the control.
RadMultiSelect Server-side Events
Below you can see a list of the server-side events available in the RadMultiSelect:
- OnDataBinding
- OnDataBound
- OnInit
- OnItemDataBound
- OnLoad
- OnPreRender
- OnItemSelected
- OnItemDeselected
- OnSelectionChanged
RadMultiSelect Public Properties and Methods
For a list with the server-side properties and methods of the control, see the Server-Side API of the RadMultiSelect class. You can also find it in the intellisense in Visual Studio.
Get Selected Items Text and Value
RadMultiSelect exposes the Text and Value server-side properties that contain the information from the DataTextField
and DataValueField
fields respectively.
Example 1: Get selected items value and text from RadMultiSelect
ASP.NET
<telerik:RadMultiSelect ID="RadMultiSelect1" runat="server" Filter="Contains" Width="400px" Placeholder="Select items...">
</telerik:RadMultiSelect>
<asp:Button ID="Button1" runat="server" Text="Get Data" OnClick="Button1_Click" />
C#
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
RadMultiSelect1.DataTextField = "textField";
RadMultiSelect1.DataValueField = "valueField";
RadMultiSelect1.DataSource = GetData();
RadMultiSelect1.DataBind();
}
}
private object GetData()
{
DataTable dt = new DataTable();
dt.Columns.Add("textField");
dt.Columns.Add("valueField");
for (int i = 0; i < 10; i++)
{
dt.Rows.Add("Item " + i, i);
}
return dt;
}
protected void Button1_Click(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);
}
}