Set "Selected Item" in the RadComboBox multi selector

Is there a way to set selected items or checked items in a multitask RadComboBox ?. I want to set the value for postback from the server.

I tried the following code, but this only works if it is not a multi-link RadComboBox.

Radbox1.SelectedValue = "123"

My front end code.

<telerik:RadComboBox ID="Radbox1" runat="server" CheckBoxes="true" EnableCheckAllItemsCheckBox="true" Width="300" Height="200" AutoPostBack="True" OnSelectedIndexChanged="Radbox1_SelectedIndexChanged" />

I have a value in Radbox1 that will be populated from the database.

Thanks Rahul

+4
source share
2 answers

When Radcombobox is set up for multiple selection using checkboxes, you must use each property marked with items.

I use the list here to simulate the elements that I want to mark after the postback. You may have this list pre-populated or it may even be loaded from the database:

enter image description here

+8
source
 protected void RadComboBox1_ItemDataBound(object sender, RadComboBoxItemEventArgs e) { if ("YourString" == e.Item.Text)) { e.Item.Checked = true; } } 

or

 protected void RadComboBox1_ItemDataBound(object sender, RadComboBoxItemEventArgs e) { List<String> yourStringList = new List<String>() {"string1","string2"}; if (yourStringList.Contains(e.Item.Text)) { e.Item.Checked = true; } } 
+1
source

Source: https://habr.com/ru/post/1446823/


All Articles