Updating database in asp net

By Daniel Roth, Rick Anderson, and Shaun Luttin ASP.

NET Core is a cross-platform, high-performance, open-source framework for building modern, cloud-based, Internet-connected applications. NET Core, you can: Millions of developers have used (and continue to use) ASP.

updating database in asp net-23

In Bind Data() method, I am getting the data from database using Sql objects and specifying the Data Source property of the Grid View to the Pages Data table of the Data Set.

When Edit link of the Grid View will be clicked then On Row Editing event will fire that will call Edit Record method.

In this method, we have to get changed values of Text Box and Drop Down list and also we need the primary key value for the record that is being edited.

To get the Primary key, I have used Data Keys property of the Grid View with the index of the row, being edited and stored into a integer variable after parsing.

In the same way you can put any kind of Validation controls inside Edit Item Template to validate the form element while user will click Update link.

For Page Name and Page Description field I want them to appear in the Text Box in edit view, so I have specified text property of Text Box as the field value in Edit Item Template and for Active field, I want it to appear as the Drop Down List so I have specified the Selected Value property as the value of the Active field.In practical scenario you should use your existing architecture to populate and update the data.In this article, I am going to take a simple database table that has following fields: Auto ID - Int, Auto Increment, Primary Key Page Name - Varchar(50) Page Description - Varchar(500) Active - Bit(1) In this article, I am not going to explain the workings of Sql objects but focusing on the events and methods of the Grid View that will help us in updating and deleting the records. For more information, see the following resources: Note The feedback system for this content will be changing soon. If content within a comment thread is important to you, please save a copy.In this article, I am going to explain how to manipulate data using Grid View control.Now let’s start with putting the Grid View on page. Data Key Names="Auto ID" Auto Generate Edit Button="True" On Row Editing="Edit Record" On Row Canceling Edit="Cancel Record" On Row Updating="Update Record" Cell Padding="4" Header Style-Horizontal Align="left" On Row Deleting="Delete Record" Row Style-Vertical Align="Top" Fore Color="#333333" Grid Lines="None" In the above code, I have kept Auto Generate Columns as false so that Grid View will not render all the fields of the data source automatically.

Tags: , ,