Thursday, 19 November 2015

Get a selected file name from fileupload control inside the gridview in asp.net

Introduction:

 I will explain here how to getting file upload control's selected file name  inside the grid view  using c#.

Explanation:


Generally we using like this to get selected file name from file upload control   "fileupload1.postedfile.filname " but  it is giving Null value instead of file name so to overcome that issue you can use as below code to get file name

 string FileName= Request.Files[0].FileName.ToString();
 string FileExtension = System.IO.Path.GetExtension(FileName);


 
if you use more than one file upload control inside the grid view
you should change files index as below code

string FileName1=Request.Files[1].FileName.ToString();
string FileName2=Request.Files[2].FileName.ToString();

No comments:

Post a Comment