Click here to Skip to main content
15,885,038 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi I created an asp.net application form inserting,updating some records in sql database and i want to be able to upload and relate uploated files to each record depending id.I have the form that you can upload files but how can i relate files with each record and on view mode see link to that file??

Thanks in advance
Posted

1 solution

Not sure if I understand your question correctly. So I'm making a few assumptions.

- I assume you want to assign a file to a record (uploaded or not doesn't really matter here)
- You want to show a Link to that file when displaying that records (again. which mode doesn't really matter)


All you need is to store the filename in a field of you record (you can also have a reference to another table etc.).

When showing the record just create a Hyperlink where you link to the folder (accessible over the web) and the file..

Example:

User uploads file "testfile.txt" you store the file to "D:\www\YourApplication\Files\testfile.txt"

When showing the link the relative path to the file could be "~/Files/testfile.txt" (Note: the tilde char (~) is representing your application root.
So you could either store "~/Files/testfile.txt" directly on the record or just the filename itself on the record and when you generate the <asp:hyperlink> control you can set the NavigateUrl Property of it to this path.
 
Share this answer
 
v2
Comments
nikolas_ar 15-Nov-13 5:47am    
Hi thanks for your reply your assumptions are correct can you give me an example of what your saying because i'm new to asp.net and in programing in general.
Nicholas Marty 15-Nov-13 6:12am    
Without having any information where and how you want to show this its pretty difficult to provide an example. If you already are accessing the database and how you render your asp page etc. you could add this to your question and I might be able to explain you better what you could do ;)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900