Hello, i've created a table with Webgrid Helper, and i add a checkbox column for each row.
Now in the second page, i want to check if the checkbox is checked, if cheched, then output one of the attribut of this row which is in the database. I don't know i can put a grid in the form or not, because if i write like this:
haixing
Member
2 Points
16 Posts
How to pass checkbox value(in webgrid) to other page ?
Jul 04, 2012 08:18 AM|LINK
Hello, i've created a table with Webgrid Helper, and i add a checkbox column for each row.
Now in the second page, i want to check if the checkbox is checked, if cheched, then output one of the attribut of this row which is in the database. I don't know i can put a grid in the form or not, because if i write like this:
in the second page i write like this:@{}I got noting in the second page.Mudasir.Khan
All-Star
15346 Points
3142 Posts
Re: How to pass checkbox value(in webgrid) to other page ?
Jul 04, 2012 08:59 AM|LINK
please check this and see if its helpful
http://haacked.com/archive/2009/04/14/using-jquery-grid-with-asp.net-mvc.aspx
http://msdn.microsoft.com/en-us/magazine/hh288075.aspx
haixing
Member
2 Points
16 Posts
Re: How to pass checkbox value(in webgrid) to other page ?
Jul 04, 2012 09:41 AM|LINK
Thanks mudasir.khan, i know we can do it with JQuery and MVC, but i want to know if i can do it with WEB PAGES only
Mikesdotnett...
All-Star
154951 Points
19870 Posts
Moderator
MVP
Re: How to pass checkbox value(in webgrid) to other page ?
Jul 04, 2012 11:58 AM|LINK
All you need to do is point the form at the second page:
Beginning ASP.NET Web Pages with WebMatrix | My Site | Twitter
haixing
Member
2 Points
16 Posts
Re: How to pass checkbox value(in webgrid) to other page ?
Jul 04, 2012 02:35 PM|LINK
Thanks Mike ! Yes this brings me to the second page, but i still can't get checkbox values because the second page don't know the "checkbox1" ...
GmGregori
Contributor
5470 Points
737 Posts
Re: How to pass checkbox value(in webgrid) to other page ?
Jul 04, 2012 04:25 PM|LINK
I can't find a good reason for what is happening to you.
Try with a form like this
<body> <div> <form method="post" action="Page2.cshtml" method="post"> @grid.GetHtml( columns: grid.Columns( grid.Column("NUM_SERIE_G","Device Number"), grid.Column("", format:@<input type="checkbox" name="checkbox1" value="@item.NUM_SERIE_G" />) ) ) <input type="submit" value="Submit" /> </form> </div> </body>and a simple Page2.cshtml like this
<body> <p>@Request["checkbox1"]</p> </body>Mikesdotnett...
All-Star
154951 Points
19870 Posts
Moderator
MVP
Re: How to pass checkbox value(in webgrid) to other page ?
Jul 04, 2012 06:24 PM|LINK
The second page will only know if the checkbox is checked. Otherwise nothing is passed.
Beginning ASP.NET Web Pages with WebMatrix | My Site | Twitter
haixing
Member
2 Points
16 Posts
Re: How to pass checkbox value(in webgrid) to other page ?
Jul 05, 2012 07:12 AM|LINK
YES, it works, thanks !!!