AtmaWeapon
03-11-2004, 02:39 PM
OK, let me explain how everything is set up, and hopefully someone can help me.
I have a DataGrid bound to a DataView. I am making a form that lets a user chose a row in a datagrid that represents the parent row of a relationship, and displays the child row data in some databound text boxes. Everything is working fine, except for the requested copy function. Here's the idea:
1. User selects a row in the parent grid.
2. User clicks button.
3. A data entry form is displayed that represents a row in the parent table. It is prefilled with data from the selected row.
4. User makes changes and saves.
5. Program saves this row to the database.
6. Program selects the newly added row.
7. Program copies old detail row into newly added detail row.
8. User edits detail data.
Everything is fine until Step 6. Because the user can sort the table, there is no guarantee that the last item will be the proper one. I have to add the parent row and sync with the database to ensure I have the right key value, and this sorts the table.
I'd love to be able to search by the key value, but if the user sorts the table, I can't use DataView.Find because it only works with the DataView's sort key. So when the user sorts the grid by a different column, I have to search the other columns. This is unreliable, as this column is not guaranteed to have unique values.
How can I search a DataView by a different sort key without disrupting the current sort? I could do a search through the cells of the DataGrid, but in some cases I'll be dealing with 1,000 or more records, and this will get very slow.
I have a DataGrid bound to a DataView. I am making a form that lets a user chose a row in a datagrid that represents the parent row of a relationship, and displays the child row data in some databound text boxes. Everything is working fine, except for the requested copy function. Here's the idea:
1. User selects a row in the parent grid.
2. User clicks button.
3. A data entry form is displayed that represents a row in the parent table. It is prefilled with data from the selected row.
4. User makes changes and saves.
5. Program saves this row to the database.
6. Program selects the newly added row.
7. Program copies old detail row into newly added detail row.
8. User edits detail data.
Everything is fine until Step 6. Because the user can sort the table, there is no guarantee that the last item will be the proper one. I have to add the parent row and sync with the database to ensure I have the right key value, and this sorts the table.
I'd love to be able to search by the key value, but if the user sorts the table, I can't use DataView.Find because it only works with the DataView's sort key. So when the user sorts the grid by a different column, I have to search the other columns. This is unreliable, as this column is not guaranteed to have unique values.
How can I search a DataView by a different sort key without disrupting the current sort? I could do a search through the cells of the DataGrid, but in some cases I'll be dealing with 1,000 or more records, and this will get very slow.