Gridview updating event in asp net

On contrary, Data Grid can declaratively bind a Data Source control but it can do it for only displaying data.

gridview updating event in asp net-53

Please keep in mind that there are many different ways to update the database using the Grid View control depending on the type of data you are updating and the functionality the user need and there are many solutions to achieve the same end result.

In the above tutorial I tried to give you one of the easiest solutions and I hope you can go explore Grid View control editing further after learning the basics from this tutorial.

This collection only requires the row index no and it will give us the primary key.

Last line of the following code is calling a local method for updating the database and passing all the parameters to this method.

You can preview the data returned by this new data source by clicking Test Query button. After the configuring Sql Data Source using above mentioned steps, drag and drop the Grid View control onto the page.

Choose previously configured Sql Data Source from Smart tag as seen below.

This is possible with new property Data Source ID which allows performing paging, sorting and all database operations directly with the Data Source.

For example, Grid View can directly update, delete and perform paging, sorting with a sqldatasource with out any custom code.

NET page that will handle different Grid View events to provide complete editing functionality.

In the Page_Load event, you simply load your data from the database and bind it with the Grid View control as shown below: For brevity I am not storing connection string in the web.config and also not using any Data Access Component.

Let's consolidate our understanding with an example.

Tags: , ,