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.This is because we didn’t binded our grid to a valid and well defined Data Source.The main goal for this time is to add inline editing functionality to the grid, in order to be able to update the imports and manage adding, editing and removing credit cards.
We will write down methods that will allow us to update, add and remove the credit card entities.
public static bool Add New Credit Card(string credit Card Name) public static bool Update Credit Card(int credit Card Id, string credit Card Name) public static string Get Credit Card(int credit Card Id) public static bool Remove Credit Card(int credit Card Id) This code is pretty straight forward.
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!
Just call Start Edit Row Java Script method that is defined on the grid (in this case I’m using s and not the Client Instance Name in order to access the grid methods, but here is basically the same) and pass the visible index of the row that we intend to put in edit mode.
Kindly this even will provide us the visible index via the function parameter which will indicate the row that user double clicked.
I will not go in the detail about the environment and developing requirements, if interested jump op to my other posts.
The attached project is written in Visual Studio 2012. Also you will need a Microsoft SQL Server 2012, Express or and more advanced version will be just fine.
The only exception is the Remove Credit Card method, which actually doesn’t delete the item and in cascade the related items in the tbl_Import, but only flags the credit card as inactive.
In order to make this thing actually work, we need to modify the stored procedure that we defined in previous post sp_Get Credit Card Imports.
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.