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

DropDownList data binding question

2 Answers 68 Views
DropDownList
This is a migrated thread and some comments may be shown as answers.
Neil
Top achievements
Rank 1
Neil asked on 23 Nov 2015, 01:06 AM

Hi,

in former WebForm projects I was using asp:DropDownList mostly in these kind of scenarios:

1) The DL was fully rendered server side and the selectable values have been populated using Object/SQL/LinqDataSource on the server.

2) The DL was two-way-bound (by the Bind or Eval statement) to a property of an arbitrary data model, e.g. in the context of a ListView or FormView.

To give you an example of the use case: Say a "status" property in a model need to have values like "On", "Off", "Unknown" and nothing else. An ObjectDataSource ensured, that the DL only contained the values for selection. Then the real model was queried in order to find the selected value and that was selected after Page_Load automatically. Once the user changed the selected value in the "status" DL, the new value was posted back to the server.

That worked fine.

I know how to achieve 1) in the "Kendo World", but I'm wondering, how I could simultaneously "two-way-bind" the DL to another model in order to set the "SelectedItem" form another data model as well as to POST finally changes made by the user.

Any pointer welcome

TIA

2 Answers, 1 is accepted

Sort by
0
Neil
Top achievements
Rank 1
answered on 24 Nov 2015, 11:01 AM
Oh... too weird?:)
0
Neil
Top achievements
Rank 1
answered on 24 Nov 2015, 10:36 PM

I realized that I can easily achieve that by using ordinary Razor "....For" elements

Closed

Tags
DropDownList
Asked by
Neil
Top achievements
Rank 1
Answers by
Neil
Top achievements
Rank 1
Share this question
or