For a while now I’m trying to figure out why my method, triggered by the Grid View.
Row Updating event, doesn’t work as all samples say it should do.
It iterates over the control collection of the Grid View Row and calls Extract Values From Cell on each cell which puts values into the dictionary.
Most of the data controls have events ending in ing and ed e.g. In most of the event handlers of the ing events it is easy to get the values from the event args.
Forgive me for the variation in my code formatting I'm trying to find the right one.
So that means when you bind to some raw collection and hook up to the Data Source property then call databind, if you try to handle the delete or update events these dictionaries are going to be empty.
Right now you must be asking yourself how can you get those dictionaries filled out just as if you were bound to a Datasource control?
If we look at this event we can see the Grid View nicely packages for us the new values, old values and the keys for the updating row.
Unfortunately these dictionaries are only filled out if you are bound to a datasource control :(.
I often see people on the forums writing code like this: Find Control is a very powerful method on Control that allows you to search for a nested control, NOT synonymous to DOM function get Element By Id.
I Often see people abusing find control and not understand that it is NOT recursive by default and complain when code like this Throws a null reference exception.
For example a Sql Data Source, which is automatically added to your Web Form if you drag-n-drop your way around Visual Studio 2005.
The problem is, I’d very much like to do so, if ASP. But I can’t set a Data Source property or anything on the Sql Data Source!!! I probably have to read the cells on the Grid View of the selected row, find the controls, get the values from those and insert those into my Data Set.
to show editing, inserting, or deleting operations in a data-bound control.