I have a gridview that, when in edit mode, I use a dropdown to load all provinces, however, when I change the province and click update, my page crashes. Im not. Row. Data. Bound, use the following code to create SELECT functionality on the row. People. Grid. ViewRow. Data. Boundobject sender, Grid. View. Row. Event. Args e. if e. Row. Row. Type Data. Control. Row. Type. Data. Row. Row. Attributesonmouseover this. Decorationunderline. Row. Attributesonmouseout this. Decorationnone. Row. Attributesonclick Client. Script. Get. Post. Back. Client. Hyperlinkthis. People. Grid. View, Select e. Row. Row. Index. Each row will then behave like a link, and when you select one it can drive the behavior of another controls on your page, possibly a Details. View allowing you to INSERT a complete record to the database. Author Paul Marshall. A self confessed Microsoft bigot, Paul loves all Microsoft products with a particular fondness for SQL Server. Paul is currently focusing on Web 2. I love the. net platform, and I find it to be the most productive toolset I have used to date. Grid. View Edit, Update and Delete Example Simple Grid. View Example with Row Edit and Delete Options. The Grid. View control in Asp. Net is useful for displaying large data in a tabular format. I have previously posted an article on how to insert new rows in database using a Grid. View. In this article however, Ill show you how a Grid. View control can be used to update edit, delete and insert data in a remote SQL Server table. Ill bind the Grid. View control with a database table using Sql. Data. Source. Meanwhile, you can go through the below link for an overview of how data binding is done using Sql. Data. Source. Start Microsoft Visual Studio and select File New Web Site from the top menu. Add a new website and in the Default. Design tab situated at the left bottom. In the design mode, select the Toolbox. From the Toolbox, drag and drop a Grid. View and Sql. Data. Source control. Attach the Grid. View with the Sql. Data. Source control, the way we have shown the link above. After you have run the website, you will see the Grid. View showing details of employees in tabular format. We have selected four columns from Employee Details table. Grid. View Edit Update Row. To edit data in a particular row, add Auto. Generate. Edit. Button and set Data. Key. NamesEmp. ID to the Grid. View control. The Data. Key. Names field will be used in the SQL query to edit the employee details. This will add an Edit link button at the beginning of all the rows in the Grid. View. Clicking the link button will trigger a Post. Back to the server requesting to edit the row values. As I have mentioned earlier, the Grid. View shows four columns and I want to edit selected columns only, lets say, the Mobile Number and Email Address. Therefore, first set Read. Onlytrue for the fields Emp. ID and Emp. Name. In ltasp Sql. Data. Source, add the Update. Command property, which will have an SQL Update command or a procedure to update the selected rows data. Add two parameters or fields inside lt. Update. Parameters property. Delete a Grid. View Row. Similar procedure must be followed to delete one row at a time. Just add Auto. Generate. Delete. Buttontrue in the Grid. View control. In the Sql. Data. Source add the below property and parameter. Delete. CommandDELETE FROM Employee. Details WHERE Emp. ID Emp. ID. Delete. Parameters. Parameter NameEmp. D. lt Delete. Parameters Thats it. There is hardly any code to be written to do these transactions. All we need is to write the SQL queries according to our need. However, there is a drawback when deleting a particular row. If a user clicks the delete button, the page will post back the delete command and the query is executed, which deletes the entire row. Without any warning. It can be very disturbing if the row was mistakenly deleted. The lost data cannot come back. Also Read Insert New Records in Database Table Using Grid. View. To cease these mistakes from happening, we need a confirmation yes or no before deleting any row in the Grid. View. To accomplish this, set Auto. Generate. Delete. Buttonfalse or remove it entirely. Delete a Grid. View Row with a Confirmation. In the Column section of the Grid. View we will add ltasp Link. Button control, which will have a client script Confirm. It will show a popup confirmation message and allows the user to either go with the delete command or negate it. Columns. ltasp Template. Field. lt. Item. Template. Link. Button Runatserver. On. Client. Clickreturn confirmAre you sure you. Command. NameDelete Deletelt asp Link. Button. lt Item. Template. Template. Field. lt Columns Recommend How to Perform a Simple CRUD Operation using a Paging Enabled Grid. View Control in Asp. Net C and Vb. Net. Markup and the Grid. View. lthtml. Grid. View Edit and Delete Rowlt title. Grid. View. IDGrid. View. 1 Font NamesArial Font SizeSmaller. Auto. Generate. ColumnsFalse. Auto. Generate. Edit. ButtonTrue. Auto. Generate. Delete. ButtonFalse. Data. Source. IDSql. Data. Source. 1. Data. Key. NamesEmp. ID. Columns. Template. Field. lt. Item. Template. Link. Button Runatserver. On. Client. Click return confirmAre you sure you. Command. NameDelete Deletelt asp Link. Button. lt Item. Template. Template. Field. ltasp Bound. Field Data. FieldEmp. ID Header. TextEmp. ID. Sort. ExpressionEmp. ID Read. Onlytrue. Bound. Field Data. FieldEmp. Name Header. TextEmp. Name. Sort. ExpressionEmp. Name Read. Onlytrue. Bound. Field Data. FieldMobile Header. TextMobile. Sort. ExpressionMobile. Bound. Field Data. FieldEmail Header. TextEmail. Sort. ExpressionEmail. Columns. lt asp Grid. View. ltasp Sql. Data. Source. IDSql. Data. Source. 1 runatserver. Connection. Stringlt Connection. Strings DNACLASSIFIEDConnection. String. Select. CommandSELECT Emp. ID, Emp. Name, Mobile, Email FROM Employee. Details. Update. CommandUPDATE Employee. Details SET Mobile Mobile, Email Email. WHERE Emp. ID Emp. ID. Delete. CommandDELETE FROM Employee. Details WHERE Emp. ID Emp. ID. Update. Parameters. Parameter NameMobile. Parameter NameEmail. Update. Parameters. Delete. Parameters. Parameter NameEmp. D. lt Delete. Parameters. Sql. Data. Source. Related How to Bind a Grid. View to a Database Table using Sql. Data. Source. Before running this site on your local host, check if the web. To check the file go to Solution Explorer and choose the web. Inside the file, find ltconnection. Strings tag and check if the connection string is properly set. User. ID, Password etc. Strings. ltadd nameDNAConnection. String connection. StringData Sourcedna. Initial CatalogDNACLASSIFIED Integrated SecurityTrue. NameSystem. Data. Sql. Client. Strings That is it. If you find this article useful, then leave a message and please dont forget to share it with your friends. Thanks for reading. Previous How to Bind Data with Grid. View using Sql. Data. Source in Asp. Net. Lock On Active True Drools Dog. Next Check if Any Grid. View Row With Radio. Button is Selected Using j. Query. Like this ArticleSubscribe now, and get all the latest articles and tips, right in your inbox. Enter your email id. Share this article.