Gridview rowupdating newvalues oldvalues
Still I will let you discover them and invent new ones.We are going to make our row editable on double click and in order to achieve that we will write down a function (in Java Script) that is going to be associated to the grids client side event called Row Dbl Click. At first we will add in our ASPX file, inside the grid definition a new section that is called Client Side Events (as we already did for other controls) and it will look like: It is that simple!Still there are a couple of tricks that we will see in the following lines.In order to start editing a certain row, we can choose the way we are going to start this action.At example you can add a Command Button in the grid itself or simply start editing let’s say on a row double click.There are also many other modes, you have rich client and server side methods in order to start editing one or more rows.If you run the example right now and double click on a row, you should see something similar to this: Even if this looks nice and simple, you maybe noticed that the fields are not editable.
You can change this easily be creating your own database and changing the connection string in the web config.
Because of this, we have our edit controls in read only state.
You can find on Devexpress support web site several issues that are speaking about this behavior and why of it. Define the following server side event: What we defined here is checking if the cells that are going in edit mode are the one we are aiming to put in edit (not the Name and Total columns) and if so we are setting a couple of properties.
As first, we are indicating the cell as read only, after that we are casing the control to an ASPx Text Box (which is the right control for these columns) and setting several parameters in order to make the editing look proper.
The most important thing is that we are assigning to each of editing cells a client side event Key Down, in which we will manage the persistence. If Enter (13) key is pressed meanwhile we are in one of editing cells, we will prevent the defaults for this action and call Update Edit method on our grid.