What are you storing in the db for the file? In your insert or update server behavior you should be storing the file name and maybe even the server file path.
When you are getting the number 1 what table does this value come from? If this id is to represent the unique identifier for the file name stored in a separate table then you will need to join this table and the one that contains the filename.
Please post back and include the details about how you are storing the file name including the tables and relationships of the info in them.