NET 2.0 Grid View control allows us to quickly edit and delete records.
However, most of the real world cases call for validating the data being edited or deleted. Drag and drop an SQL Data Source control on the web form.
The Grid View will subsequently have various controls inside it such as Text Box and drop down lists.Scott Mitchell March 2007 Summary: This is the Visual C# tutorial.(Switch to the Visual Basic tutorial.) In this tutorial, we'll see how easy it is to add validation controls to the Edit Item Template and Insert Item Template of a data Web control, to provide a more foolproof user interface.When the user clicks the Update link button the grid's Row Command Event fires.Within here I want to perform validation against existing records in the database.To cancel the update operation, set the collections, if necessary, before the values are passed to the data source.A common way to use these collections is to HTML-encode the values supplied by the user before they are stored in the data source. (19 printed pages) Download the code for this sample.Introduction Step 1: Replicating the Example from "Tutorial 17: Examining the Events Associated with Inserting, Updating, and Deleting" Step 2: Converting the Bound Fields into Template Fields Step 3: Adding the Validation Controls to the Grid View's Edit Item Templates Step 4: Summarizing Data-Entry Problems Step 5: Adding the Validation Controls to the Details View's Insert Item Template Step 6: Partitioning the Validation Controls into Validation Groups Conclusion The Grid View and Details View controls in the examples we've explored over the past three tutorials have all been composed of Bound Fields and Check Box Fields (the field types automatically added by Microsoft Visual Studio when binding a Grid View or Details View to a data source control through the smart tag).If a user makes a data-entry mistake—such as omitting the Product Name field or entering an invalid value for Units In Stock (such as -50) —an exception will be raised from within the depths of the application architecture.While this exception can be gracefully handled as demonstrated in the previous tutorial, ideally the editing or inserting user interface would include validation controls to prevent a user from entering such invalid data in the first place.