TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Ajitender Vijay
NA
263
120.6k
MVC Get view values in controller
Jul 22 2013 7:30 AM
Hi Friends, i am new in MVC, I'm have a product list with textbox and user enter no. of qty in textbox .now i want to get all entered qty in controller on button click
.csHtml Code
@model IEnumerable<CSLOrderingMVC.Models.Entity.Product>@{
Layout = "~/Views/Shared/_Site.cshtml";
ViewBag.Title = "Product";
}
@using ( Html.BeginForm("SaveQuantity","Products"))
{
<div class="clearfix" style="float: left; position: relative;">
<table cellpadding="10" cellspacing="2" border="0">
<tr bgcolor="#fbcaca">
<td>
<b>Code</b>
</td>
<td>
<b>Product Name</b>
</td>
<td>
<b>Unit Price</b>
</td>
<td>
<b>Qty</b>
</td>
</tr>
@foreach (var item in Model)
{
<tr bgcolor="#cccccc">
<td>
@item.ProductCode
</td>
<td>
@item.ProductName
</td>
<td>
@item.Price
</td>
<td>
@Html.TextBox("txtProductQty")
</td>
</tr>}
</table>
</div>
<input type="submit" value="Proceed to basket" />
}
Controller Code
[HttpPost]
public ActionResult SaveQuantity(FormCollection formCollection)
{
foreach (var key in formCollection.Keys)
{
var value = formCollection[key.ToString()];
// etc.
}
return View();
}
Reply
Answers (
3
)
Populating One Dropdownlist with selection of other DropDown
Erorr in code