Gridview rowupdating e cancel
Gridview rowupdating e cancel - www cupid compredating
NET 2.0 Grid View control allows us to quickly edit and delete records.
Next, drag and drop a Required Field Validation control below the Text Box.
We will use the Custom Validator control for this purpose.
Just like we attached the Required Field Validator control to the Text Box, attach a Custom Validator to the Contact Name column. If you run the web form and try entering wrong value in the Contact Name column then you will see the error message displayed as before and the value will not be accepted by the Grid View control.
Click on the "Advanced" button and check the "Generate INSERT, UPDATE and DELETE statements" checkbox (Figure 3). Now that you have configured the SQL Data Source control let's bind it with a Grid View control. Open its smart tag and configure it as shown in Figure 4.
Here, we set the Data Source of the Grid View to Sql Data Source1. We also enable paging, sorting and editing features of the Grid View.
There can be several approaches taken for validating data. For our example we are going to use Customers table of Northwind database. Open its smart tag and choose "Configure Data Source" option to start Configure Data Source wizard.
On the first step of the wizard click on "New Connection" button to open a dialog as shown in Figure 1. There are multiple ways in which one can get the data from the current row that is being edited in a Grid View. Using "Extract Values From Cell": This is an easy way to get all the values from the current row. In my case this was happening because I was binding to a List of custom objects.Set the Control To Validate property of Required Field Validator control to Text Box1 (i.e. Also, set its Error Message property to "Please enter company name".Note that by default all validation controls validate on the client side.This way you can attach client side validation controls to the Grid View columns.