jquery updates and deletes asp.net MVC data _jquery

Source: Internet
Author: User

Before learning asp.net mvc, learn and apply, manipulate data display, add, edit, update and delete functions.
Many methods are interlinked to see how they are convenient, fast and efficient.
Today, the practice of insus.net writing is to update and delete the data bound to the table directly.
In the project, create an entity, that is, communicate to the database and manipulate the data:

Public ienumerable<toollocation> getalltoollocations () {sp. ConnectionString = DB.
   ConnectionString; Sp.
   Parameters = null; Sp.
   procedurename = "Usp_toollocation_getall"; DataTable dt = sp. ExecuteDataset ().
   Tables[0]; Return dt.
  Tolist<toollocation> (); public void Update (toollocation tl) {list<parameter> param = new list<parameter> () {New P Arameter ("@ToolLocation_nbr", Sqldbtype.smallint, 2, TL. TOOLLOCATION_NBR), New Parameter ("@LocationName", Sqldbtype.nvarchar,-1,tl. LocationName), New Parameter ("@Description", Sqldbtype.nvarchar,-1,tl. Description), New Parameter ("@IsActive", Sqldbtype.bit,1,tl.
   IsActive)}; Sp. ConnectionString = DB.
   ConnectionString; Sp.
   Parameters = param; Sp.
   procedurename = "Usp_toollocation_update"; Sp.
  Execute (); public void Delete (toollocation tl) {list<parameter> param = new list<parameter> () {New P Arameter ("@ToolLocation_nbr", SqldbType.smallint, 2, TL.
   TOOLLOCATION_NBR)}; Sp. ConnectionString = DB.
   ConnectionString; Sp.
   Parameters = param; Sp.
   procedurename = "Usp_toollocation_delete"; Sp.
  Execute ();
 }

In the controller of the project:

Create a view and bind the data:

@using Insus.NET.Models; @model ienumerable<toollocation> <! DOCTYPE html>  

Source Code

The jquery code for the above steps #4:

Run it and see the effect:


The above is the function of updating the data, the following implementation is to delete the data in the table.

@using Insus.NET.Models; @model ienumerable<toollocation> <! DOCTYPE html>  

The jquery code labeled #4, which is the core function of deletion:

Run the program to see the effect of the deletion:

After the deletion is successful, we do not need to redirect, just delete this line of HTML to achieve:

The above is the entire content of this article, I hope to help you learn, but also hope that we support the cloud habitat community.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.