Assign file path to FileUpload Control

2019-03-01 08:19发布

问题:

How can i assign file path to FileUpload Control in VS 2005?

Why i need that?: 'cause, when i edit a row in GridView, the fileupload control becomes blank (which i believe is correct but client doesn't!!!) and a validation is thrown saying "File to be upload is not selected".

回答1:

This is not possible due to security restrictions. The only way to set that property on the FileUpload control is to have the user make a selection.

But other solution is make use of lable control to display file path rather than file upload control. and when use click to upload file hide lable and display file upload control.