I have a page with two LoadOnDemand ComboBox controls. Both controls get their data from a common data access method. The first controls works. The second control never displays the items. It does display the header and the status message.
I double-checked that the controls have unique client id in the rendered html. Any suggestions?
I double-checked that the controls have unique client id in the rendered html. Any suggestions?
<table> |
<tr> |
<td> |
<telerik:RadComboBox ID="rcbGenContractor" runat="server" Width="450px" |
DropDownWidth="510px" HighlightTemplatedItems="True" EnableLoadOnDemand="True" |
OnItemsRequested="rcbGenContractor_ItemsRequested" ShowMoreResultsBox="True" |
EnableVirtualScrolling="True" Skin="Sunset"> |
<HeaderTemplate> |
<ul> |
<li class="col1">Name</li> |
<li class="col2">City/St</li> |
<li class="col3">Signatory</li> |
<li class="col4">ID</li> |
</ul> |
</HeaderTemplate> |
<ItemTemplate> |
<ul> |
<li class="col1"><%# DataBinder.Eval(Container, "Text") %></li> |
<li class="col2"><%# DataBinder.Eval(Container, "Attributes['CitySt']") %></li> |
<li class="col3"><%# DataBinder.Eval(Container, "Attributes['Signatory']")%></li> |
<li class="col4"><%# DataBinder.Eval(Container, "Attributes['Id']") %></li> |
</ul> |
</ItemTemplate> |
</telerik:RadComboBox> |
</td> |
</tr> |
<tr valign="top"> |
<td> |
<telerik:RadComboBox ID="rcbSubContractor" runat="server" Width="450" |
DropDownWidth="510px" HighlightTemplatedItems="true" EnableLoadOnDemand="true" |
OnItemsRequested="rcbSubContractor_ItemsRequested" ShowMoreResultsBox="true" |
EnableVirtualScrolling="true" Skin="Sunset"> |
<HeaderTemplate> |
<ul> |
<li class="col1">Name</li> |
<li class="col2">City/St</li> |
<li class="col3">Signatory</li> |
<li class="col4">ID</li> |
</ul> |
</HeaderTemplate> |
<ItemTemplate> |
<ul> |
<li class="col1"><%# DataBinder.Eval(Container, "Text") %></li> |
<li class="col2"><%# DataBinder.Eval(Container, "Attributes['CitySt']") %></li> |
<li class="col3"><%# DataBinder.Eval(Container, "Attributes['Signatory']")%></li> |
<li class="col4"><%# DataBinder.Eval(Container, "Attributes['Id']") %></li> |
</ul> |
</ItemTemplate> |
</telerik:RadComboBox> |
</td> |
</tr> |
</table> |
protected void rcbGenContractor_ItemsRequested(object o, Telerik.Web.UI.RadComboBoxItemsRequestedEventArgs e) |
{ |
if (e.Text.Length < 3) |
{ |
e.Message = "Enter at least 3 letters..."; |
} |
else |
{ |
SearchContractors(e); |
} |
} |
protected void rcbSubContractor_ItemsRequested(object o, Telerik.Web.UI.RadComboBoxItemsRequestedEventArgs e) |
{ |
if (e.Text.Length < 3) |
{ |
e.Message = "Enter at least 3 letters..."; |
} |
else |
{ |
SearchContractors(e); |
} |
} |
private void SearchContractors(Telerik.Web.UI.RadComboBoxItemsRequestedEventArgs e) |
{ |
int totalItems = default(int); |
int endItem = e.NumberOfItems; |
int ITEM_BATCH_SIZE = 20; |
List<JobDataLayer.ContractorItem> data = |
dataLayer.SearchContractors(e.Text, e.NumberOfItems, ITEM_BATCH_SIZE, out totalItems); |
e.EndOfItems = e.NumberOfItems + ITEM_BATCH_SIZE >= totalItems; |
foreach (JobDataLayer.ContractorItem contractor in data) |
{ |
RadComboBoxItem item = new RadComboBoxItem(); |
item.Text = contractor.Name; |
item.Value = contractor.Id.ToString(); |
string CitySt = contractor.City; |
if (!String.IsNullOrEmpty(contractor.State)) |
{ |
if (CitySt.Length > 0) |
CitySt += ", "; |
CitySt += contractor.State; |
} |
item.Attributes.Add("CitySt", CitySt); |
item.Attributes.Add("Signatory", contractor.Signatory ? "X" : ""); |
item.Attributes.Add("Id", contractor.Id.ToString()); |
rcbGenContractor.Items.Add(item); |
item.DataBind(); |
endItem++; |
} |
e.Message = String.Format("Items <b>1</b>-<b>{0}</b> out of <b>{1}</b>", endItem.ToString(), totalItems.ToString()); |
} |