Click here to Skip to main content
12,349,228 members (59,300 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as

Stats

35.1K views
4 bookmarked
Posted

Get Checked Rows In a Webgrid Using Checkbox MVC3

, 9 Feb 2012 CPOL
Rate this:
Please Sign up or sign in to vote.
MVC3 webgrid does not return rows collection, here is a tip to get several objects selected
/*Assuming in a webgrid, someone wants to get a collection of objects that have been checked. MVC3 only returns a single object that has been selected and a count of all rows.
To get a few rows from the webgrid that have been checked, here is a tip on how to do it.

1. Wrap the div containing WebGrid inside a form to be submited */

   @using (Html.BeginForm("Assign","Home"))
   {
     <div id="grid">
        @grid.GetHtml(
        tableStyle: "grid",
        headerStyle: "head",
        alternatingRowStyle: "webgrid-alternating-row",
        columns: grid.Columns(grid.Column(header: "Assign?", format:@<text><input class="check-box"  id="assignChkBx"name="assignChkBx" type="checkbox" value="@item.Id"/></text>

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Winstan
Kenya Kenya
No Biography provided

You may also be interested in...

Comments and Discussions

 
Questionis Webgrid is compatible Pin
Member 943750928-Sep-12 2:16
memberMember 943750928-Sep-12 2:16 
AnswerRe: is Webgrid is compatible Pin
Winstan12-Nov-12 21:36
memberWinstan12-Nov-12 21:36 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.160621.1 | Last Updated 9 Feb 2012
Article Copyright 2012 by Winstan
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid