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

[Solved] Edit popup and dropdown list

0 Answers 96 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Marcin
Top achievements
Rank 1
Marcin asked on 20 Jul 2011, 07:55 AM
I found much topics about this problem and no good solution.
Edit grid in popup mode.
Questions:
1. How to set selected value equal to model properties on DropDownList?
2. How to retrieve selected value and bond to model properties when i want to save edited record?

What i have now is:
Part of my Editor Template

@Html.LabelFor(model => model.RoleName)

@Html.DropDownListFor(model => model.RoleName,

 

new SelectList(ViewBag.Roles, "RoleId", "RoleName", Model.RoleName))

DropDown list is filled correctly, but how to set selected Value equal to model properties?
I tried:

 

@Html.Telerik().DropDownListFor(model => model.RoleName).Name(

 

"ddlRoles").BindTo(new SelectList(ViewBag.Roles, "RoleId", "RoleName", (List<PoCo.Role>)ViewBag.Roles).Find(delegate(PoCo.Role item) { return item.RoleId == Model.RoleId; })).RoleId))

 

 

 

and mutation of this, no one works. Never my value is not selected.
Next - i totally dont know how to retrieve value after i save.
Thanks for help

Tags
Grid
Asked by
Marcin
Top achievements
Rank 1
Share this question
or