Can't you put the file extension in the DB as another column?
Then when you do the initial query of the files, send the extension
column as well. You don't have to display the extensions in the
grid, but the grid will hold the information none the less for each
file. So when you click the file, merely append the extension on
for it.
IE something like
In the grid's onChange() event handler:
filename = MyGrid.selectedItem.FileName + "." +
MyGrid.selectedItem.Extension;
The syntax might vary depending on scripting language you are
using in your particular code.