I need to add the dynamic row in jquery datatable and in ajax success event. but i am getting the undefined method error. Please find the below code and help me to solve.
Controller:
- [HttpPost]
- public ActionResult SaveItems(Int32 customer, Int32 product, Int32 quantity, Int32 saleId)
- {
- if (saleId > 0)
- {
- TBL_Sale obj = new TBL_Sale();
- obj.CustomerId = customer;
- obj.CreatedBy = 1;
- obj.CreatedDate = DateTime.Now;
- objDb.TBL_Sale.Add(obj);
- objDb.SaveChanges();
- }
- TBL_SaleItems saleItemId = SaveIndividualItem(product, quantity, saleId);
- return View(saleItemId);
- }
- public TBL_SaleItems SaveIndividualItem(Int32 product, Int32 quantity, Int32 saleId)
- {
- TBL_Stock objStock = objDb.TBL_Stock.Where(w => w.ProductId == product).SingleOrDefault();
- TBL_SaleItems obj = new TBL_SaleItems();
- obj.ProductId = product;
- obj.Qty = quantity;
- obj.SaleId = saleId;
- obj.PricePerQty = objStock.PricePerQty;
- obj.StockId = objStock.Id;
- obj.SuplierId = objStock.SupplierId;
- obj.Amount = objStock.PricePerQty * quantity;
- objDb.TBL_SaleItems.Add(obj);
- objDb.SaveChanges();
- return obj;
- }
View Code:
- @section Scripts {
- }
- class="container">
- ="form-horizontal" action="/action_page.php">
class="form-group">- "text" class="typeahead tt-query" autocomplete="off" spellcheck="false">
- ="control-label col-sm-1" for="txCustomer">Customer
class="col-md-8">- "text" class="form-control" id="txCustomer" placeholder="Customer" name="Customer">
class="col-md-2">- class="btn btn-default">Submit
class="form-group">- ="control-label col-sm-1" for="txtProduct">Product
class="col-md-2">- "text" class="form-control" id="txtProduct" placeholder="Product Name" name="Product">
- ="control-label col-sm-1" for="txtProductCode">Product
class="col-md-2">- "text" class="form-control" id="txtProductCode" placeholder="Product Code" name="ProductCode">
- ="control-label col-sm-1" for="txtQuantity">Quantity
class="col-md-2">- "text" class="form-control" id="txtQuantity" placeholder="Quantity" name="Quantity">
class="col-md-1">- onclick="return fnClickAddRow();" class="btn btn-default">Submit
class="row">- @Html.Partial("_BillingGrid")
class="row" id="divTotal">- ="form-horizontal" action="/action_page.php">
class="form-group">- ="control-label col-sm-1" for="txtProduct">Cash Type
class="col-md-3">- ="form-control">
- ="control-label col-sm-1" for="txtProduct">Discount(%)
class="col-md-2">- ="form-control">
- ="control-label col-sm-1" for="txtProductCode">Discount
class="col-md-1">- "text" class="form-control" id="txtProductCode" placeholder="Product Code" name="ProductCode">
class="col-md-1">- class="btn btn-default">Print
class="form-group">- ="control-label col-sm-1" for="txtQuantity">Quantity
class="col-md-3">- "text" class="form-control" id="txtQuantity" placeholder="Quantity" name="Quantity">
- ="control-label col-sm-1" for="txtItems">Items
class="col-md-2">- "text" class="form-control" id="txtItems" placeholder="Items" name="Items">
- ="control-label col-sm-1" for="txtAmount">Amount
class="col-md-1">- "text" class="form-control" id="txtAmount" placeholder="Total Amount" name="Total Amount">
class="col-md-1">- class="btn btn-default">Cancel
Thiyagarajan EPosted Aug 21, 2019, 6:31 AM