当前位置:网站首页>Addition, deletion, query and modification of data
Addition, deletion, query and modification of data
2022-04-23 06:24:00 【Wood acridine】
Data addition, deletion, query and modification
First instantiation entity model

Inquire about
LINQ Standard query statement
Declare a variable :var a =from Variable in data source . Specific table
select Variable Query the data of the whole table
return json(a, JsonRequestBehavior.AllowGet) Return the data

newly added
In the page, first give the new button a click event , Define a method to pop up the new modal form , Call this method
example :
Submit the page data to the controller Complete a new operation
First get the data in the form , You can get one by one , You can also serialize forms
serialize
So let's define a variable , adopt ID The selector finds what needs to be serialized from Forms . serializeArray();
example :var dataArr = $("#frm").serializeArray(); Serialize the form as An array
Submit
use post Method
$.post(“URL”, Data submitted ,function( Receive the data returned by backfilling ){
alert(); Pop up the return value
Close modal box :$(“ Of the modal box ID”).modal(“hide”);
Save update page :window.location.reload(dataArr);
});
Method of submitting new data
Define methods
example :public ActionResult InsertStudent(SYS_Student modStudent){}( Receive data through entity class methods )
Define a variable to store information about the success or failure of the new addition
string str= "";
add to : Instantiated entity model . Data sheet .Add();
example :myModel.SYS_Student.Add(modStudent);
Data saving operation : Instantiated entity model . SaveChanges();
example :myModel.SaveChanges() ;
Finally, return the information to
return json(str,JsonRequestBehavior . AllowGet);
modify
- Select the data to be modified . Pop up the modified mode box
$(“ Of the modal box ID”).modal(“show”);
- Display the data to be modified in the modal box
Define a method in the controller through ID Find out the data
get data
$.post(URL, Data transferred { attribute : Property value },function(){
Data binding
$(ID).val(); adopt ID Find and assign
example :$("#upStudentName").val(data[0].studentName);
})
- Modify the save function in the mode box ( Modify the function )
Define a method in the controller to receive the data transmitted from the page
example :public ActionResult UpdateStudent(SYS_Student modStudent)
Define a variable to store information about the success or failure of the modification
string str= "";
adopt Entry() Pass the modified data back . Status code
example :myModel.Entry(modStudent).State = System.Data.Entity.EntityState.Modified;
Data saving operation : Instantiated entity model . SaveChanges();
example :myModel.SaveChanges() ;
Finally, return the information to
return json(str,JsonRequestBehavior . AllowGet);
Define the saving method in the modify mode box in the page
So let's define a variable , adopt ID The selector finds what needs to be serialized from Forms
example :var arrData = $("#frmModify").serializeArray();
Submit data
use post Method
$.post(“URL”, Data submitted ,function( Receive the data returned by backfilling ){
alert(); Pop up the return value
Close modal box :$(“ Of the modal box ID”).modal(“hide”);
Save update page :window.location.reload();
});
Delete
Write a input label , The type is
Define a method on the page
A query box pops up asking whether to delete data
if (window.confirm(" Delete this data ")) {
Declare a variable to get the of the element value value
use post Method
$.post(“URL”, Data submitted ,function( Receive the data returned by backfilling ){
alert(); Pop up the return value
Save update page :window.location.reload();
});
Define a method in the controller
example :public ActionResult DeleteStudent(int studentID)
Define a variable to store information about the success or failure of deletion
string str= "";
according to ID First query out the data to be deleted
The first method :linq Standard query
example :
The second method :lamda The method of expression
example :
adopt Remove() Method to delete the data to be deleted
example :myModel.SYS_Student.Remove(student);
Data saving operation : Instantiated entity model . SaveChanges();
example :myModel.SaveChanges() ;
Finally, return the information to
return json(str,JsonRequestBehavior . AllowGet);
版权声明
本文为[Wood acridine]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204210616405391.html
边栏推荐
- 对比学习论文——[MoCo,CVPR2020]Momentum Contrast for Unsupervised Visual Representation Learning
- Example of reentrant lock thread waiting to wake up
- Algèbre linéaire chapitre 2 - matrice et son fonctionnement
- Three ways to create threads
- A sharp tool to improve work efficiency
- SQL injection
- 检测技术与原理
- Installation and usage skills of idea
- Best practices for MySQL storage time
- Denoising paper - [noise2void, cvpr19] noise2void learning denoising from single noise images
猜你喜欢

IO multiplexing of 09 redis

Kibana search syntax

Mysql database foundation

自动控制(韩敏版)

Kalman filter and inertial integrated navigation

Chapter 3 of linear algebra - Elementary Transformation of matrix and system of linear equations
![How to use comparative learning to do unsupervised - [cvpr22] training & [eccv20] image translation](/img/33/780b80693f70112eebc10941f7c134.png)
How to use comparative learning to do unsupervised - [cvpr22] training & [eccv20] image translation

Pytorch learning record (V): back propagation + gradient based optimizer (SGD, adagrad, rmsporp, Adam)

Detection technology and principle

LDCT图像重建论文——Eformer: Edge Enhancement based Transformer for Medical Image Denoising
随机推荐
Algèbre linéaire chapitre 2 - matrice et son fonctionnement
Chapter 4 of line generation - linear correlation of vector systems
Guaba and Computational Geometry
Common programming records - parser = argparse ArgumentParser()
自動控制(韓敏版)
Preparedstatement prevents SQL injection
Pyqy5 learning (2): qmainwindow + QWidget + qlabel
[leetcode 67] sum of two binary numbers
Pyqt5 learning (I): Layout Management + signal and slot association + menu bar and toolbar + packaging resource package
Illustrate the significance of hashcode
Three ways to create threads
C3p0 database connection pool usage
Mysql database foundation
In depth understanding of the relationship between dncblevel and noise denoising in the paper
Algèbre linéaire chapitre 1 - déterminants
LockSupport. Park and unpark, wait and notify
Paper on LDCT image reconstruction: edge enhancement based transformer for medical image denoising
How to grow at work
IO multiplexing of 09 redis
In depth source code analysis servlet first program