[b][red]This message was edited by lsobio at 2002-8-6 13:42:41[/red][/b][hr]
[b][red]This message was edited by lsobio at 2002-8-6 13:41:29[/red][/b][hr]
I would like to know if anyone knows how to capture an insert event using the Vb.Net data grid. I cannot find an event that captures the mode the data grid is in (Update or Insert). We are writing a windows application that uses web services to retrieve information from our database. The application will be installed at our Mexico plants.
By default you can update and insert records on the .Net data grid. If the user is allowed to update any column on an existing record, then inserting a new record is a piece of cake because you dont have to worry about setting all columns as editable. But there are certain times when the user is not allowed to update all the columns on an existing record (example: Style Code, Style Description, Style Type, Modified User, Modified Date) when you are in update mode columns [Style Code], [Modified User] and [Modified Date] are read only, so the user can only modify columns [Style Description] and [Style Type]. But if the user wants to add a new record then Column [Style Code] must now be editable and system enters values in columns [Modified User] and [Modified Date].
The problem I am facing is that I am using a grid that can be used for updating existing records and inserting new records. By default the grid is always in update mode so I am setting some of the columns to read only, but when the user intends to insert a new record I need to set all of the columns as editable. Currently I am using a context menu to determine when the user intends to insert a record, so the user right clicks on the grid and a context menu appears giving him the option to insert a new record. As the user clicks on insert I create a new data row and append it to the dataset the grid is bound to. After the user inputs the new data and clicks out of the new row, I set the grid back to update mode by setting some of the columns to read only. Furthermore, when the user wants to save his changes I now must capture all the rows that where updated and insert them in a dataset and also capture all the new rows that where inserted and insert them in a dataset.
Afterwards I call a method from a web service and pass in the datasets.
I avoid passing back the original dataset because if the dataset had 1000 rows and only 3 rows where updated, then by capturing only the updated rows I will end up sending a dataset with only 3 rows across the web, which makes the save procedure much faster.
This technique works ok, but not to my satisfaction.
If anyone knows a simpler way of doing these actions please let me know.