This is a migrated thread and some comments may be shown as answers.

2nd LoadOnDemand Combo does not display entries

4 Answers 35 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Paul Schaeflein
Top achievements
Rank 1
Paul Schaeflein asked on 26 Mar 2010, 06:15 AM
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?

<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());  
 
    }  
 

4 Answers, 1 is accepted

Sort by
0
Veronica
Telerik team
answered on 29 Mar 2010, 04:36 PM
Hi Paul,

I inspected your code but I could not find anything which could cause the problem. I noticed that you are using JobDataLayer namespace. Could you please provide this as well so we can run and test your project?

Thank you.

Veronica Milcheva
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Paul Schaeflein
Top achievements
Rank 1
answered on 29 Mar 2010, 04:40 PM
That code is not relevant to the issue, and depends on my database which I cannot give to you.

The point is that two combo boxes use the same ObjectDataSource to populate On-Demand. I used the IE Developer toolbar to view the HTML DOM and it appears that the items for both controls are put into the same <DIV> element.
0
Accepted
Veronica
Telerik team
answered on 31 Mar 2010, 02:26 PM
Hello Paul Schaeflein,

After inspecting your code in details I've noticed that you are calling this:

rcbGenContractor.Items.Add(item);

only for the first RadComboBox rcbGenContractor. You add items nowhere in your code for the second RadComboBox rcbSubContractor. That's the reason why only the first combo is displaying it's items.

You may add the ID of the RadComboBox as a first argument in SearchContractors function and that way each of the RadComboBoxes will add items to itself.

Please let me know if this was helpful.

Greetings,
Veronica Milcheva
the telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Paul Schaeflein
Top achievements
Rank 1
answered on 31 Mar 2010, 02:28 PM
Yes, that is it! Thanks!

(It is always good to have a second set of eyes to look at code.)
Tags
ComboBox
Asked by
Paul Schaeflein
Top achievements
Rank 1
Answers by
Veronica
Telerik team
Paul Schaeflein
Top achievements
Rank 1
Share this question
or