Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public ActionResult AddCustomerLinkToDB(string IsSeleted)
- {
- string selectedCustomer = IsSeleted;
- return View();
- }
- @using (Html.BeginForm("AddCustomerLinkToDB", "Admin", FormMethod.Post))
- {
- <table class="table table-bordered table-hover">
- <tr>
- <th>Customer ID</th>
- <th>Customer Name</th>
- <th>Select this user</th>
- </tr>
- @foreach (var item in Model)
- {
- <tr>
- <td>@item.Id</td>
- <td>@item.Name</td>
- <td>@Html.RadioButton("IsSelected", new { id = item.Id })</td>
- </tr>
- }
- </table>
- }
- public class ViewModel
- {
- // since the CustID is numeric, I prefer using 'int' property
- public int IsSelected { get; set; }
- public List<Customer> Customers { get; set; }
- // other properties
- }
- @model ViewModel
- @using (Html.BeginForm("AddCustomerLinkToDB", "Admin", FormMethod.Post))
- {
- <table class="table table-bordered table-hover">
- <tr>
- <th>Customer ID</th>
- <th>Customer Name</th>
- <th>Select this user</th>
- </tr>
- @foreach (var item in Model.Customers)
- {
- <tr>
- <td>@item.Id</td>
- <td>@item.Name</td>
- <td>@Html.RadioButtonFor(model => model.IsSelected, item.Id, new { id = item.Id })</td>
- </tr>
- }
- </table>
- }
- [HttpPost]
- public ActionResult AddCustomerLinkToDB(ViewModel model)
- {
- int selectedCustomer = model.IsSelected;
- // other stuff
- return View();
- }
Add Comment
Please, Sign In to add comment