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

[Solved] LoadOnDemand Default Value

1 Answer 160 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Atlas
Top achievements
Rank 1
Atlas asked on 17 Jul 2009, 05:22 PM
I am using the LoadOnDemand Combo example you provided:

 

<telerik:RadComboBox ID="RadComboBox1" runat="server" Width="250px" Height="150px"

 

 

 

EmptyMessage="Select a Company" EnableLoadOnDemand="True" ShowMoreResultsBox="true"

 

 

 

EnableVirtualScrolling="true" OnItemsRequested="RadComboBox1_ItemsRequested">

 

 

 

</telerik:RadComboBox>

 

 


 

protected void RadComboBox1_ItemsRequested(object sender, RadComboBoxItemsRequestedEventArgs e)

 

{

 

 

DataTable data = GetData(e.Text);

 

 

 

int itemOffset = e.NumberOfItems;

 

 

 

int endOffset = Math.Min(itemOffset + ItemsPerRequest, data.Rows.Count);

 

e.EndOfItems = endOffset == data.Rows.Count;

 

 

 

for (int i = itemOffset; i < endOffset; i++)

 

{

RadComboBox1.Items.Add(

 

new RadComboBoxItem(data.Rows[i]["CompanyName"].ToString(), data.Rows[i]["CompanyName"].ToString()));

 

}

 

e.Message = GetStatusMessage(endOffset, data.Rows.Count);

}

 


This combobox is going to appear on an edit page, and I need to set the default selected value when the page loads. How do I do that?

My problem is very similar to this: http://www.telerik.com/community/forums/aspnet-ajax/combobox/selectedvalue-and-loadondemand.aspx

The control is in a FormView, but the control is attempting to bind when the page loads and the RadComboBox1_ItemsRequested event has not fired.  If I am only pulling back a subset of records, how does it no to get the item that matches the existing value?

1 Answer, 1 is accepted

Sort by
0
Veselin Vasilev
Telerik team
answered on 21 Jul 2009, 08:52 AM
Hello Nano Sacay,

Please find attached a sample project. It uses a load on demand RadComboBox in FormView.

I hope this will get you started.

Regards,
Veselin Vasilev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
ComboBox
Asked by
Atlas
Top achievements
Rank 1
Answers by
Veselin Vasilev
Telerik team
Share this question
or