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.