I don't feel like this is adequately called out in the Telerik documentation and it caused me some grief, so I thought I would post it here for others who may be stuck in the same situation.
When binding a RadComboBox with a custom ItemTemplate and attempting to use ItemDataBound, it will not work. You will get an empty template even though if you trace through with the debugger you see values in the ItemDataBound event.
The solution is to avoid using the ItemDataBound when using an ItemTemplate. Instead you'll need to manually create the RadComboBoxItems inside the ItemsRequested event.
When binding a RadComboBox with a custom ItemTemplate and attempting to use ItemDataBound, it will not work. You will get an empty template even though if you trace through with the debugger you see values in the ItemDataBound event.
The solution is to avoid using the ItemDataBound when using an ItemTemplate. Instead you'll need to manually create the RadComboBoxItems inside the ItemsRequested event.
protected
void
IncrementalSearchEvent(
object
sender, RadComboBoxItemsRequestedEventArgs e)
{
ClientBLL clientBLL =
new
ClientBLL();
var clients = clientBLL.IncrementalSearch(e.Text, Int32.Parse(rdoStatus.SelectedValue), 4);
foreach
(NameValuePair client
in
clients)
{
CachePerson obj = ObjectTools.GetObjectPerson(client.Value);
RadComboBoxItem item =
new
RadComboBoxItem();
item.Attributes[
"FirstName"
] = obj.FirstName;
item.Attributes[
"LastName"
] = obj.LastName;
item.Text = obj.FullName;
item.Value = obj.PersonId.ToString();
selSelectedClient.Items.Add(item);
}
selSelectedClient.DataBind();
}
<
telerik:RadComboBox
ID
=
"selSelectedClient"
runat
=
"server"
Skin
=
"Telerik"
EnableLoadOnDemand
=
"true"
onitemsrequested
=
"IncrementalSearchEvent"
>
<
HeaderTemplate
>
<
table
border
=
"0"
width
=
"590"
>
<
tr
>
<
td
width
=
"100"
>First Name</
td
>
<
td
width
=
"100"
>Last Name</
td
>
</
tr
>
</
table
>
</
HeaderTemplate
>
<
ItemTemplate
>
<
table
border
=
"0"
width
=
"590"
><
tr
>
<
td
width
=
"100"
><%# DataBinder.Eval(Container, "Attributes['FirstName']")%></
td
>
<
td
width
=
"100"
><%# DataBinder.Eval(Container, "Attributes['LastName']")%></
td
>
</
tr
>
</
table
>
</
ItemTemplate
>
</
telerik:RadComboBox
>