:-) Here's another one that's bugging me.....again in VB.NET 2005 and windows forms.
After selecting an account from a dropdownlist, I am populating a datagrid with items that correspond to that account. Really, I just wanted to display a summary of the items in the datagrid, and then pass the internal key from whatever record that is selected. From whatever was selected I would populate textboxes and allow the user to edit parts of the data. I've used datagrids to edit things before, and didn't have much luck with reliably controlling how the user edited the data. I tried a selectbox (I think?) but I liked how the datagrid gave me column headings, plus allowed you to sort on the fly by clicking on the column headings. Anyway....
I've got a datatable being filled from SQL, and am binding that to a datagrid. I'm filling it with my primary key, and then making invisible that column so the user doesn't see it. I've got it set up so clicking the in the datagrid selects the whole row, the user can't edit rows, etc., and that all works. I'm getting the primary key with this:
and this seems to work just fine. The problem is, after I've selected a row, if I try to click on a column heading to resort the grid, the program crashes. I'm guessing I need to get the selected row/key differently, or reset something when I click on a column header, but I wanted to know why it was happening and what I should do to fix it. I guess I could just disable sorting on column headers (can I do this?), but it would be neat to be able to keep that in. Maybe I'm just selecting the row wrong, or getting the info from the selected row wrong? Any help would be greatly appreciated. Thanks!!