I've got a problem with filling RadComboBox. Every time, the user clicks on the scrollbar all items are added again.
My RadComboBox looks like (its within a table):
And my CS-Code looks like:
In den Page_Load-Event I do nothing, beceause I don't want to load all the items beacause it takes too long. And I can't use WebService, because I need to get the value from the ComboBox in an other ComboBox with:
My RadComboBox looks like (its within a table):
| <telerik:RadComboBox ID="radComboBoxPLZ" Runat="server" Width="50px" DropDownWidth="260px" MaxHeight="200px" |
| OnItemsRequested="radComboBoxPLZ_ItemsRequested" EnableLoadOnDemand="true" MarkFirstMatch="true" |
| CollapseDelay="100" TabIndex="1"> |
| <HeaderTemplate> |
| <table style="width: 220px" cellspacing="0" cellpadding="0"> |
| <tr> |
| <td style="width: 40px;"> |
| PLZ</td> |
| <td style="width: 120px;"> |
| Gemeinde</td> |
| <td style="width: 20px;"> |
| Kanton</td> |
| </tr> |
| </table> |
| </HeaderTemplate> |
| <ItemTemplate> |
| <table style="width: 220px" cellspacing="0" cellpadding="0"> |
| <tr> |
| <td style="width: 40px;"> |
| <%# DataBinder.Eval(Container, "Text")%> |
| </td> |
| <td style="width: 120px;"> |
| <%# DataBinder.Eval(Container, "Attributes['Gemeinde']")%> |
| </td> |
| <td style="width: 20px;"> |
| <%# DataBinder.Eval(Container, "Attributes['Kanton']")%> |
| </td> |
| </tr> |
| </table> |
| </ItemTemplate> |
| </telerik:RadComboBox> |
| protected void radComboBoxPLZ_ItemsRequested(object sender, RadComboBoxItemsRequestedEventArgs e) |
| { |
| if (e.Text.Length < 1) |
| return; |
| string sqlSelectCommand = string.Format("Select p.PLZ, k.Gemeinde, k.Kanton from AAV_TEST_PLZ_ORTE_GEMEINDE p, AAV_TEST_GEMEINDE_KANTON k where p.KANT_GEM_ID = k.ID and p.PLZ LIKE '{0}%' ORDER BY p.PLZ", e.Text); |
| DataTable dataTable = null; |
| using (OleDbDataAdapter adp = new OleDbDataAdapter(sqlSelectCommand, AdresssucheParameter.ConnectionString)) |
| { |
| dataTable = new DataTable(); |
| adp.Fill(dataTable); |
| } |
| foreach (DataRow dataRow in dataTable.Rows) |
| { |
| RadComboBoxItem item = new RadComboBoxItem(); |
| item.Text = (string)dataRow["PLZ"]; |
| item.Value = dataRow["PLZ"].ToString(); |
| //zusätzliche Spalten |
| item.Attributes.Add("Gemeinde", dataRow["Gemeinde"].ToString()); |
| item.Attributes.Add("Kanton", dataRow["Kanton"].ToString()); |
| radComboBoxPLZ.Items.Add(item); |
| item.DataBind(); |
| } |
| } |
string
plz = e.Context["FilterStringPLZ"].ToString();
I'm looking for an solutin since 2 days and can't find an answer. It's very frustrating because I'm testing with yout Trial Version - when it looks good, we would like to pay the software.
Thanks for your anser! Bye