Hi,
I have in a control a ComboBox where item are load on Demand.
When we whant to update the data i try to retreive the value with SelectedValue but off course the list is empty.
I alreay read many item on this forum but i cannot find any solution about this!!!!
What is the solution for this problem please?
The code is:
C# code is:
I suppose on my method SetValues, I need to load the parent customer. But all? if I try to load all customer in the comboBox, i have a error on the method OnItemDataBound!!!!!
Any idee about a solution?
Thanks,
Edwin.
I have in a control a ComboBox where item are load on Demand.
When we whant to update the data i try to retreive the value with SelectedValue but off course the list is empty.
I alreay read many item on this forum but i cannot find any solution about this!!!!
What is the solution for this problem please?
The code is:
<telerik:RadComboBox runat="server" ID="ddl_ParentCustomer" Width="410px" Height="300px" |
EnableLoadOnDemand="true" HighlightTemplatedItems="true" EnableVirtualScrolling="true" |
OnItemsRequested="RadComboBoxCustomerOnItemsRequested" OnItemDataBound="RadComboBoxCustomerOnItemDataBound" |
EmptyMessage="-Selecteer-"> |
<HeaderTemplate> |
<table border="0" cellpadding="0" cellspacing="0" width="100%"> |
<tr> |
<td style="width: 220px;"> |
ComapanyName |
</td> |
<td style="width: 50px;"> |
ZipCode |
</td> |
<td> |
City |
</td> |
</tr> |
</table> |
</HeaderTemplate> |
<ItemTemplate> |
<table border="0" cellpadding="0" cellspacing="0" width="100%"> |
<tr> |
<td style="width: 220px;"> |
<%# Eval("Name")%> |
</td> |
<td width="50px;"> |
<%# Eval("ZipCode")%> |
</td> |
<td> |
<%# Eval("City")%> |
</td> |
</tr> |
</table> |
</ItemTemplate> |
</telerik:RadComboBox> |
C# code is:
I suppose on my method SetValues, I need to load the parent customer. But all? if I try to load all customer in the comboBox, i have a error on the method OnItemDataBound!!!!!
protected void RadComboBoxCustomerOnItemsRequested(object o, RadComboBoxItemsRequestedEventArgs e) |
{ |
string sFilter = e.Text; |
// safety check |
if (sFilter.Length > 100 || sFilter.IndexOf(";") != -1) return; |
ddl_ParentCustomer.Items.Clear(); |
var customers = (from c in Customer.GetAllParentCustomers() |
where c.Name.StartsWith(sFilter) |
select new |
{ |
CustomerId = c.Id, |
c.Name, |
c.ZipCode, |
c.City |
}).Page((e.NumberOfItems / 20) + 1, 20).ToList(); |
ddl_ParentCustomer.DataSource = customers; |
ddl_ParentCustomer.DataBind(); |
} |
protected void RadComboBoxCustomerOnItemDataBound(object sender, RadComboBoxItemEventArgs e) |
{ |
object o = e.Item.DataItem; |
e.Item.Text = o.GetType().GetProperty("Name").GetValue(o, null).ToString(); |
e.Item.Value = o.GetType().GetProperty("CustomerId").GetValue(o, null).ToString(); |
} |
public void SetValues(Customer customer) |
{ |
if(customer.ParentCustomerId > 0) |
{ |
ddl_ParentCustomer.SelectedValue = customer.ParentCustomerId.ToString(); |
} |
} |
Any idee about a solution?
Thanks,
Edwin.