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

[Solved] Server side binding selectedvalue to property (NOT the list)?

3 Answers 113 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Pat
Top achievements
Rank 1
Pat asked on 02 Mar 2011, 04:39 AM
I see how to bind a combobox to a lookup table, but how do I set the value of a property on the model's business object into the combo box? I only see SelectedIndex?

I have a model that contains an order. I'm getting the order status combobox to populate with the available order status codes and descriptions.  But I don't see how to now also bind the combo box to the OrderStatus property of the order object in my model.

3 Answers, 1 is accepted

Sort by
0
Georgi Krustev
Telerik team
answered on 03 Mar 2011, 09:23 AM
Hello Pat,

 
Currently ComboBox and DropDownList UI components have only Selectedindex method for selecting item.
Value method which allows you to select item depending on its value will be added in the next official release of Telerik components for ASP.NET MVC.

For now you can select correct item using SelectList object which returns list of SelectListItem. This demo uses SelectList to bind ComboBox UI component.


Best wishes,
Georgi Krustev
the Telerik team
Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
0
Pat
Top achievements
Rank 1
answered on 03 Mar 2011, 05:02 PM
I don't understand your example.

I see that in the first combobox you are using SelectList to populate the combo with a list of objects that contain ProductID and ProductName.  I don't see anywhere else in that snippet where you are giving the ComboBox a ProductID from your model to default to. It looks like you are simplying using some other property on the ComboBoxAttributes to set the selectedindex.

In my case I have a Model that contains two Properties, .BusinessObject, and .LookupTables . The business object represents ONE record out of the db, and it will contain a property like OrderStatusID, or in your case ProductID. The .LookupTables property can contain any other number of properties for the various lists needed on that page.  I would pass .LookupTables.OrderStatuses to the BindTo method.

How/where in your current code would I set/bind  .BusinessObject.OrderStatusID ?
0
Accepted
Georgi Krustev
Telerik team
answered on 07 Mar 2011, 06:23 PM
Hello Pat,

 
I have created a test project which shows how to use SelectList (check BindToSelectList.aspx page). It is attached to this message.

If the problem still persists I will ask you to send us a simple test project which shows how you are trying to bind ComboBox UI component. Thus I will be able to check it locally and advice you further.

Regards,
Georgi Krustev
the Telerik team
Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
Tags
ComboBox
Asked by
Pat
Top achievements
Rank 1
Answers by
Georgi Krustev
Telerik team
Pat
Top achievements
Rank 1
Share this question
or