Edit this page

Adding items programmatically

RadCheckedDropDownList supports adding items at run time, which means that you can manually populate it with data. The following example demonstrates how to add two different items to the RadCheckedDropDownList.Items collection.

You can use one of the following item types:

  • RadCheckedListDataItem – it represents a logical data item which can display specific text, image and checkbox.

  • DescriptionTextCheckedListDataItem – similar to the RadCheckedListDataItem. In addition, it displays some description below the item’s text.

Figure 1: Sample RadCheckedListDataItem and DescriptionTextCheckedListDataItem

dropdown-and-listcontrol-checkeddropdownlist-adding-items-programmatically 001

Add items programmatically

RadCheckedListDataItem dataItem = new RadCheckedListDataItem();
dataItem.Text = "Chicken toast";
radCheckedDropDownList1.Items.Add(dataItem);

DescriptionTextCheckedListDataItem descriptionItem = new DescriptionTextCheckedListDataItem();
descriptionItem.Text = "Chicken wings";
descriptionItem.Checked = true;
descriptionItem.DescriptionText = "some description";
radCheckedDropDownList1.Items.Add(descriptionItem);

Dim dataItem As New RadCheckedListDataItem()
dataItem.Text = "Chicken toast"
radCheckedDropDownList1.Items.Add(dataItem)
Dim descriptionItem As New DescriptionTextCheckedListDataItem()
descriptionItem.Text = "Chicken wings"
descriptionItem.Checked = True
descriptionItem.DescriptionText = "some description"
radCheckedDropDownList1.Items.Add(descriptionItem)

See Also