Gridview rowediting and rowupdating
Connection string must be based on your database details. Drag the gridview control from tool box and placed into the page and make it Autogeneratecolumns as false, so manually we will create the gridview columns to display.Copy the below code and paste into aspx page as shown below.“Select” – Raises the Selected Index Changing and Selected Index Changed events. “Update” – Raises the Row Updating and Row Updated events. I need to do the Select and Edit in the code behind because I have to change schema prefix in the sql statement depending on the current user.And here I’m explaining some basic functions of this gridview control such as insert edit and delete a record.
“Delete” – Raises the Row Deleting and Row Deleted events. “Page” – Raises the Page Index Changing and Page Index Changed events.
In general, gridview control is used to populate the data in tabular format from different datasources and basically it derived from webcontrol class.
Actually gridview control is built with lot of features and this control is commonly used for all applications.
In this article, we will explore how to add, update, delete and select a record from sql server database using gridview control in a simple way.
I’m using visual studio 2008 and sql server 2008 for this sample.
I came across a very interesting error while using buttons/link buttons in the Grid View for editing the Grid View rows data.