wintersc says:
Here what kind of DataType value for hd.FileUpload property is also in hd.save what you are saving? I am saving a FileUpload Id to a table called helpdesk.
1) Check your stored procedure there is no any Column which store the Id value. Also how can you will get the uploaded file as you have not maintained any Uploaded file id.
wintersc says:
In btnUpload you already saving the file in tblFiles table so what you are trying to do in hd.Save by using FileUpload1.HasFile value? Correct. I need the File Upload Id to save in the helpdesk table, but the file that is uploaded is saved to a table titled tblFiles. So, When the end-user clicks the btnSubmit, the File Upload ID is not saving in the helpdesk table.
2) You are not maintaining any relational values in both the Tables tblfiles as well as helpdesk so how can you say FileUploadId will save in other table. There is no such column value in both the tables which will retain the common column value in both table
There is no use of below code line in btnSubmit . Remove it and check the below suggestion to maintain the Uploaded file relationship in both table
wintersc says:
hd.FileUpload = Convert.ToString(FileUpload1.HasFile);
i) You need to add FileId as identity column in tblfiles and call the file upload code in btnSubmit_click before the hd.Save() method where you need to return the uploaded FileId from database.
Refer the below link how to return Identity column value and you just need to store it in int type variable and pass it to hd object by adding new property with name as FileId in class and set its value which return from the tablefiles fileId and then pass it to hd.FileId.
Return Identity value from Stored Procedure in SQL Server
ii) Also you need to add column name as FileId as Int type in table helpdesk and need to modify the sp spInsertHelpDeskTicket. You need to add Parameter as @Fileid also value of @FileId need to store in column name as FileId in table helpdesk also modify the code in Save method.
So as per suggestion you can retain the relation of the uplodedfile in both the tables on btn_Submit click.