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

Post multiple checkboxes as list/array

1 Answer 50 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.
JULIA
Top achievements
Rank 1
JULIA asked on 15 Oct 2010, 06:51 PM
Hello,

in the attached sample is use multiple checkboxes and post this as list to the action method. in a normal form the asp.net modelbinder binds the values from the checkboxes as int array to the action parameter.
[HttpPost]
public ActionResult Save( MyModel model, int[] events )
{
    // events is not empty
}

if i try this inside the grid, nothing will bound. please can you provide a working sample for this issue?
[GridAction]
[HttpPost]
public ActionResult _Save( MyModel model, int[] events )
{
    // events is empty
}

<h1>Editor for Events</h1>
<table>
    <tbody>
        <tr>
            <td><input value="1" type="checkbox" name="Events" />Event 1</td>
            <td><input value="2" type="checkbox" name="Events" />Event 2</td>
            <td><input value="3" type="checkbox" name="Events" />Event 3</td>
            <td><input value="4" type="checkbox" name="Events" />Event 4</td>
        </tr>
    </tbody>
</table>

Regards,
Timo

1 Answer, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 18 Oct 2010, 01:25 PM
Hello Timo,

 The problem stems from the fact that you are using Ajax binding. For server binding everything would have worked as expected (just like the standalone form). Fortunately there is an easy workaround which involves subscribing  to the OnSave event. Find attached the modified project.

Regards,
Atanas Korchev
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
Grid
Asked by
JULIA
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Share this question
or