I have written as
protected void btnUpload_Click(object sender, EventArgs e)
{
HttpFileCollection fileCollection = Request.Files;
for (int i = 0; i < fileCollection.Count; i++)
{
HttpPostedFile uploadfile = fileCollection[i];
string fileName = Path.GetFileName(uploadfile.FileName);
if (uploadfile.ContentLength > 0)
{
uploadfile.SaveAs(Server.MapPath("~/UploadFiles/") + fileName);
lblMessage.Text += fileName + "Saved Successfully<br>";
hyperlnk.Text = fileName.ToString() + "Saved Successfully<br>";
// hyperlnk.Attributes.Add("href", Server.MapPath("/UploadFiles/") + fileName);
hyperlnk.NavigateUrl="~/UploadFiles/" + fileName;
//lblMessage.Text= "<a href=" + "/UploadFiles/" + fileName +">"+fileName+"</a>";
}
}
}
When we Upload multiple files, only one of them is displayed in link as shown in screenshot
Please help me
You appear to have a single hyperlink object, accessed via a variable called hyperlnk
.
If you want to have multiple links, you'll need to create multiple links.
(You can see all the label text, because you're appending to the label text on each iteration of the loop, whereas you're replacing the hyperlink text/url. You can't just append to the hyperlink, because you want to have several independent links.)
See more on this question at Stackoverflow