Gridview editing updating deleting in asp net
In previous post we discussed how to create 3 – tier architecture application using c#.we already discussed about 3 – tier architecture layers Presentation Layer, Business Logic Layer and Data Access Layer.Now, In this article i will explain you how to bind data to gridview and edit, update, delete data in gridview in using 3 – tier architecture. Net web application First open the visual studio and create a new web application.open visual studio – In above screen we can see, there are five column in User Mst Table in sql.The first column is ID which is identification of user, so it must be unique.Here we set ID column Primary Key and Auto Increment by updating the ID column property.In this article I explained it using Bound Field In my Next Article I will show How to Edit Update Grid View Using Template Field.There are several ways for getting those dynamically generated textbox values we use that in different scenarios.
By using the Grid View Row object we can find the reference of any control in the row in which user is editing the data.
To explain further about how to bind data in gridview and perform insert update and delete operations, we need to create database table to read data and bind retrieved resultset to gridview, so simply execute following script to sql query editor to create database table and then add few records manually or download complete example code with script at the end of the page. Best practice is to use parameterized query to perform select, insert, update or delete operations instead simple sql statements.
Here is the script to create “Subject Details” table: Note: To avoid SQL Injections and security purpose, I used parameterized query in my following example code.
In my previous tutorials, I’d explained about how to bind data to gridview, how to get connection string, gridview inline insert update delete, difference between executereader executenonquery executescalar and other more cracking tutorials on Grid View, Asp.net, SQL Server here.
Now here in this tutorial, I’ll explain how to show data in gridview and then insert update delete gridview records (perform CRUD operation) in using c# as well as with example code.These properties will automatically render Edit, Update and Cancel buttons inside Grid View column.