Gridview is not updating

Rated 3.90/5 based on 838 customer reviews

With the help row variable, I am going to find all the controls placed under that row in edit mode using Find Control property.After finding the controls I am using them to pass their values to the parameter of the Sql Command object that is ultimately updating the records into database.In this method, I am specifying the Edit Index property of the Grid View to -1.As there is no row at -1 position so Grid View will be shown in normal mode.After that again, I am doing the same thing that I had done in Cancel Record method, I mean setting Edit Index property of the Grid View to -1 and rebinding the data again by calling Bind Data() method.When Delete link of the Grid View will be clicked, it will confirm the user whether they really want to Delete the record, if they will click OK, it will fire On Row Deleting event of the Grid View that will call Delete Record method.Please note that when you will not bind the data again, Grid View will not change in edit mode.When Cancel link is clicked on Grid View in edit mode, On Row Canceling Edit event will fire that will call Cancel Record method.

In this method, we have to get changed values of Text Box and Drop Down list and also we need the primary key value for the record that is being edited.You can notice that I have kept Required Field Validator too inside the Edit Item Template as I want the textbox to be validated for empty data.In the same way you can put any kind of Validation controls inside Edit Item Template to validate the form element while user will click Update link.I have specified Data Key Names as Auto ID, the primary key of the database table.Then I have several methods attached with following events Get video of hundreds of ASP. On Row Editing - Edit Record On Row Cancel Edit - Cancel Record On Row Updating - Update Record On Row Deleting - Delete Record As I set Auto Generate Columns property to false so I am going to manually write the fields name that I need to appear in the way I want.

Leave a Reply