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

EnableLoadOnDemand When Editing.

10 Answers 152 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Craig Hinkel
Top achievements
Rank 1
Craig Hinkel asked on 17 Dec 2008, 03:49 PM
I'm using the radcombox in one of my form templates with the EnableLoadOnDemand turned on. I was wondering how do you handle the situation when in edit mode and you need to select an item for an existing record? For example, I use a StatusID for the data value and the StatusNm for the text display (which is a concatenation of two columns from the table). I saw an example where you dont use ID's, but rather the name for the value and text and this is not an option in our real world.

Thanks

10 Answers, 1 is accepted

Sort by
0
Simon
Telerik team
answered on 18 Dec 2008, 05:23 PM
Hello Craig Hinkel,

Could you clarify what do you mean by "edit mode"?

Please provide more information about your goal.

Thank you in advance.

Sincerely yours,
Simon
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Craig Hinkel
Top achievements
Rank 1
answered on 18 Dec 2008, 05:25 PM
I simply mean selecting a default value (for example, editing a customer record).
0
Simon
Telerik team
answered on 20 Dec 2008, 01:12 PM
Hi Craig Hinkel,

You could use the <%# Bind %> expression to bind the SelectedValue property of the ComboBox, which is inside the Template, to a field in the data source.

Please see this Code Library Project for an example of a RadComboBox inside Edit and Insert Templates of a FormView.

Regards,
Simon
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Craig Hinkel
Top achievements
Rank 1
answered on 05 Jan 2009, 05:21 PM
If I set the SelectedValue to say 5, how is the loadondemand going to work then since it uses the typed in text? I only allow the webservice to be called when the text is not equal to an empty string. does that make sense?
0
Simon
Telerik team
answered on 08 Jan 2009, 01:15 PM
Hello Craig Hinkel,

When binding the Grid you could create and add each RadComboBox Item with the data coming from the data base.

Further when you start typing in the ComboBox it will call the Web Service to load new Items.

Both functionalities should not interfere with each other.

Please let me know if I have missed something.

All the best,
Simon
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Craig Hinkel
Top achievements
Rank 1
answered on 08 Jan 2009, 01:23 PM
I'm sorry, I do not think I am explaining my use case properly. Let me start over :)

 I have a screen used for editing and adding orders. There is a radcombobox control that loads a list of customers using loading on demand. When I load the radcombobox, I use the customers first name, lastname, and email as the display text and the customer id as the value.

Here is where the problem lies. When "editing" an existing order, I need to select the appropriate customer in the radcombobox, but it seems very code smelly to take the orders customer id, find the customer, then concatenate first name, lastname, and email and set the radcombobox's text property.

Does this make more sense?
0
Celestyn
Top achievements
Rank 1
answered on 09 Jan 2009, 04:15 PM
Thanks. What a simple solution. I still searched for some complicated coding.

Now I add

... AppendDataBoundItems="True" ...

and

<

Items>

 

 

<telerik:RadComboBoxItem Value="current key of binded field" Text="current value" Selected="True" />

 

 

</Items>

and it works like a charm.

 

0
Simon
Telerik team
answered on 10 Jan 2009, 03:48 PM
Hi Craig Hinkel,

Thank you for clarifying.

In this case I suggest you use the following approach: in case the page is opened for edit and the Customer Id is supplied, simply load the necessary Items (or just that of the current Customer) on the server and display it in the ComboBox.

In this way, you will have both the edited Customer selected and the Load on Demand functionality available at the same time.

Regards,
Simon
0
cheburek
Top achievements
Rank 1
answered on 27 Aug 2010, 11:09 AM
Hi Simon
I know that this thread is quite old but it is still actual.
Could you please provide a little example on that (bind default value for combobox on page load, where text is of type System.String and value is integer ID)?
I.e. a sample code with desired functionality on edit screen

<asp:TextBox Id="tbCode" runat="server" Text='<%# Bind("Code") %>' />
<telerik:RadComboBox runat="server" Id="cbCustomer"
SelectedValue='<%# Bind("CustomerId") %>'
Filter="Contains" EnableLoadOnDemand="True">
<WebServiceSettings Path="~/AppCode/myService.asmx" Method="ReportCustomerList" />
</telerik:RadComboBox>
<asp:ObjectDataSource ID="dataTableSrc" runat="server" SelectMethod="Collect"
    TypeName="MyProjectNamespace.DatamanagerClass"
    InsertMethod="Insert" UpdateMethod="Update">
    <InsertParameters>
        <asp:Parameter Name="Code" Type="String" />
        <asp:Parameter Name="CustomerId" Type="Int32" />
    </InsertParameters>
    <UpdateParameters>
        <asp:Parameter Name="Code" Type="String" />
        <asp:Parameter Name="CustomerId" Type="Int32" />
    </UpdateParameters>
</asp:ObjectDataSource>

Thanks in advance
0
Simon
Telerik team
answered on 27 Aug 2010, 01:17 PM
Hi cheburek,

Please see this Code Library Project for more information and a lot of sample code. I believe it will get you on the right track.

Sincerely yours,
Simon
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
Tags
ComboBox
Asked by
Craig Hinkel
Top achievements
Rank 1
Answers by
Simon
Telerik team
Craig Hinkel
Top achievements
Rank 1
Celestyn
Top achievements
Rank 1
cheburek
Top achievements
Rank 1
Share this question
or