Monthly Archives: March 2011

RadComboBox – FindItemByText

I have become a massive fan of the Telerik controls. They make development so much easier than the out of the box controls, which enables rapid application development that meets your clients needs. I believe every Software shop should have a site licence for either these controls or some other commercial vendor’s equivalent.

The small thing which I am showcasing today is from the RadComboBox control (from Telerik’s ASP.NET AJAX controls).

The FindItemByText method. This method enables you to retrieve a particular RadComboBoxItem by way of its text value, rather than its key. If you actually need to do this, you have probably done something wrong in your design. But assuming there can be no duplicates in the RadComboBox, it is a pretty handy method.

Usage:

// Show the value of an item using its Text to get the value
string lecturer = lecturerRadComboBox.FindItemByText("Reno Raines").Value.ToString();

This can be really handy as well for marking a particular item in the RadComboBox as selected:

lecturerRadComboBox.FindItemByText("Reno Raines").Selected = true;