Gridview rowupdating commandfield
This way you don't have to repopulate the data source every page postback.This saves time but it depends on how long you can tolerate "old data" being displayed.i want to say one more thing i call the display method at the end of every event which i handled ....like onrowupdating event after performing all operation i call display method at the end.If you do a Data Bind in your Page Load event every page request (without checking if is Postback is False) then you will be overwritting anything that the user provided.BUT this information that I'm telling you does not matter to you because you don't care about anything the user has entered into the Grid View for editing.When this event fired it saves the values at their view state & this view state is sent to the client. NET controls used to access the data in your C#/VB. If you do a Data Bind in the Page Load event then all of this data is lost!Edit: if you do a Data Bind in the Page Load event every page request all of your data will be lost It's the most common problem that people have with Grid Views that I've noticed.
But do you notice how you are calling the display() method in several different places?Actually I made a data acces layer class, buiness logic layer class & presentation layer(page). In most of the books generally direct update query is written on aspx page under sql data source using update commnad property & do updation in grid view. Now i do not want to use update command or connection string in sql data source.This thing I have done in data acces layer class where I make a method of an update.Data Bind method to bind the Grid View to the data source.I do this in the Page Pre Render event for a bunch of reasons...example if you bind in the Page Load event every page request you will have problems with getting the values that the user entered while editing (because these values will be over written with the data that you've bound to).