I am having a little trouble working with Data grids. I have the code to pull data from a DB using select statements and I put this data into a data table.
hen I set the DataGrid.datasource = to the data table. It works fine. My problem comes in when I try to edit the data. I need help working with the data grid. I want the user to double click the grid and have the row they double clicked appear in a new form for editing. SO I take the value for each column in the ROW selected and place them in Text boxes/combo boxes and allow the user to edit. Then when they save I want the updated data returned to the grid. I have it all almost working now. I know there is a better way but Here is how I do it,
When the user double clicks the grid I define a temp data table = DataGrid.datasource and set the current row of the temp table = to DataGrid.currentRowIndex. Then I pull the data from the Temp Table and populate the form. When the data is saved I just update the temp table and set the DataGrid.datasource = to the temp table. This is very sloppy I think. But here is the real problem. When the datagrid gets sorted by the user in some manor and I set the temp table = to the datagrid.datasource they are no longer sorted the same. The temp table gets the original sort order and the currentRowIndex on the Grid no longer points to the correct row in my table. I understand this problems comes from my poor method of handling the data grid and I would like a better solution and not a fix for my current method. Thanks for any help.