Hi
In below code it is showing Null Values in ObjProduct
[HttpPost] public ActionResult CreateEdit(Product objProduct) { if (ModelState.IsValid) { dbProduct.Add(objProduct); } return RedirectToAction("Index"); }
@using (Html.BeginForm("CreateEdit", "Product", FormMethod.Post)) { <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span><span class="sr-only">Close</span></button> <h4 class="modal-title">Add New Product</h4> </div> <div class="modal-body"> <div class="form-group row"> <label for="Id" class="col-sm-3 col-form-label">Id</label> <div class="col-sm-6"> <input type="Text" class="form-control" id="Id" placeholder="Product Id"> </div> </div> <div class="form-group row"> <label for="Description" class="col-sm-3 col-form-label">Description</label> <div class="col-sm-9"> <input type="text" class="form-control" id="Description" placeholder="Description"> </div> </div> <div class="form-group row"> <label for="PType" class="col-sm-3 col-form-label">Product Type</label> <div class="col-sm-6"> <input type="text" class="form-control" id="PrType" placeholder="Product Type"> </div> </div> <div class="form-group row"> <label for="IsActive" class="col-sm-3 col-form-label">IsActive</label> <div class="col-sm-2"> <input type="text" class="form-control" id="txtIsActive" placeholder="Active"> </div> </div> </div> <div class="modal-footer"> <button type="submit" class="btn btn-primary">Save changes</button> <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button> </div> </div> </div> </div> }
@foreach (var item in Model) { <tr> <td> @Html.DisplayFor(modelItem => item.Id) </td> <td> @Html.DisplayFor(modelItem => item.Description) </td> <td> @Html.DisplayFor(modelItem => item.PrType) </td> <td> @Html.DisplayFor(modelItem => item.IsActive) </td> <td> <a class='btn btn-primary btn-sm' id='btnEdit'><i class='fa fa-pencil'></i> Edit </a> </td> </tr>
Thanks