Asked by:
Need help on how to save editable table contents to database model - ASP.NET MVC

Question
-
User-1381715179 posted
Hi,
I would like help on <g class="gr_ gr_4 gr-alert gr_gramm gr_inline_cards gr_run_anim Grammar only-del replaceWithoutSep" id="4" data-gr-id="4">the my</g> Order request form with order details to which I have added an editable table with which I don't have experience but I would like to calculate the total and save records to <g class="gr_ gr_22 gr-alert gr_gramm gr_inline_cards gr_run_anim Grammar only-ins replaceWithoutSep" id="22" data-gr-id="22">database</g> model.
Thanks,
Monday, October 8, 2018 12:15 PM
All replies
-
User-369506445 posted
hi
here is a good sample that shows how to create an editable table
Monday, October 8, 2018 12:31 PM -
User-271186128 posted
Hi YoungRich,
I would like help on the my Order request form with order details to which I have added an editable table with which I don't have experience but I would like to calculate the total and save records to database model.From your description, if you want to calculate the total on client side, you could use the JQuery change event, when you change the textbox value, in its change event, you could loop through the table row or column to calculate the total. More details, you can refer to this article:
Then, please refer to the following articles to submit the form data using JQuery Ajax method.
https://www.mikesdotnetting.com/article/220/posting-data-with-jquery-ajax-in-asp-net-razor-web-pages
https://www.c-sharpcorner.com/blogs/post-the-data-to-asp-net-mvc-controller-using-jquery-ajax
Best regards,
DillionTuesday, October 9, 2018 2:48 AM -
User-1381715179 posted
<g class="gr_ gr_12 gr-alert gr_spell gr_inline_cards gr_run_anim ContextualSpelling multiReplace" id="12" data-gr-id="12">Thanks</g> you so much Dillion, could you please help with an effective saving and retrieving method of table contents to the database model.
Thanks,
Tuesday, October 9, 2018 7:03 AM -
User-369506445 posted
for save and retrieve from the database, you can use Entity Framework or ADO.NET, if your mean was another thing please more describe
Tuesday, October 9, 2018 7:10 AM -
User-271186128 posted
Hi YoungRich,
could you please help with an effective saving and retrieving method of table contents to the database model.Do you mean you want to retrieve the selected row data (from the table) and save them into the database? If that is the case, please refer to the following articles:
https://forums.asp.net/t/1770199.aspx?How+to+get+the+cell+values+of+selected+row+with+using+jquery
Best regards,
DillionWednesday, October 10, 2018 6:22 AM -
User-647250237 posted
Here, for creating:
[HttpPost] public ActionResult Create(DoctorViewModel model) { if (ModelState.IsValid) { model.Doctor.DoctorAddress = model.DoctorAddress; model.Doctor.DoctorCharge = model.DoctorCharge; db.Doctors.Add(doctor); db.SaveChanges(); return RedirectToAction("Index"); } return View(doctor); }
Wednesday, October 17, 2018 5:33 AM -
User-2054057000 posted
Basically you just want to Insert data from your form in asp.net mvc to your database. MVC has 2 important components.
- View - where you will have your form in html
- Controller - where you will have the C# code that will get the data from the form.
The Controller will get the View's data (which you fill in the form) through Model Binding concept. And the Controller will insert the data to the database using Entity Framework (a popular OR/M).
Since it looks you are just beginning with MVC therefore I would suggest you to have some basic understanding about:
- Model Binding Concept.
- Entity Framework Concept.
I good tutorial which will take you forward in this is - here.
Wednesday, October 17, 2018 12:41 PM