Are you using a hidden column in your DataGrids to store the ID of rows? I was until recently when I discovered that you can specify a field on the DataGrid which contains the keys. It goes a little something like this
<asp:DataGrid id="MyGrid" runat="server" DataKeyField="TheFieldInDataSourceWhichContainsTheUniqueKey">...
In code you can retrieve the key in a command event handler or something similar like this
Neat little trick which keeps your DataGrids a little bit cleaner :)
You can of course use any data type as the data key, just change the cast to the appropriate type and you're all set :)
The opinions expressed herein are my own personal opinions and do not represent
my employer's view in any way.