Hi,
try this way you can get your requirement.
place this code in datalist of item template
<asp:linkbutton id="LinkButton1" runat="server" commandargument="<%#Eval("filepath") %>" commandname="Download" xmlns:asp="#unknown">Download</asp:linkbutton>
and code behind just use what u wrote
if (e.CommandName == "Download")
{
string URL = e.CommandArgument.Tostring();
FileInfo fileInfo = new FileInfo(URL);
if (fileInfo.Exists)
{
Response.Clear();
Response.AddHeader("Content-Disposition", "attachment; filename=" + fileInfo.Name);
Response.AddHeader("Content-Length", fileInfo.Length.ToString());
Response.ContentType = "application/octet-stream";
Response.Flush();
Response.WriteFile(fileInfo.FullName);
}
}
All the Best