Skip to content

About

.NET, ASP.NET MVC, MVC Data Editors

Topics

Resources

Stars

3 stars

Watchers

53 watching

Forks

Latest commit

 

History

76 Commits

Folders and files

Repository files navigation

Data Editors for ASP.NET MVC - How to use data editors to edit Model fields

This example demonstrates how to use data editors in bound and unbound modes to edit Model fields.

Use editors to edit Model fields

Overview

Use the editor's PreRender property to specify multiple selected items based on the enumerable Model field.

settings.PreRender = (sender, e) => {
    ASPxCheckBoxList cbl = (ASPxCheckBoxList)sender;
    foreach(ListEditItem item in cbl.Items) {
        item.Selected = Model.ProgLanguages.Contains((int)item.Value);
    }
};

Call the editor's GetSelectedValues method to get multiple selected items on the Controller side. To obtain Model fields from the corresponding editor, use a DevExpressEditorsBinder object.

public ActionResult Index([ModelBinder(typeof(DevExpressEditorsBinder))] MyModel model) {
    model.ProgLanguages = CheckBoxListExtension.GetSelectedValues<int>("ProgLanguagesUnbound");
    TempData["PostedModel"] = model;
    return RedirectToAction("Success");
}

Files to Review

Does This Example Address Your Development Requirements/Objectives?

(you will be redirected to DevExpress.com to submit your response)

About

.NET, ASP.NET MVC, MVC Data Editors

Topics

Resources

Stars

3 stars

Watchers

53 watching

Forks

Releases

Packages

Used by

Contributors

Languages