If you want to open the file normally then you can use
Response.Redirect(YourFilePath)
. And if you want to download the file then you can use the function below. Call the function in your RowCommand Event of GridView and pass the path of corresponding file. Try this:
<asp:LinkButton ID="lnkView" runat="server" Text="View Document" CommandName="View" CommandArgument='<%#EVal("URL")%>'/>
protected void Gridview_RowCommand(Object sender, GridViewCommandEventArgs e)
{
if(e.CommandName == "View")
{
DownloadFile(e.CommandArgument.ToString());
}
}
public void DownloadFile(string FilePath)
{
Response.Clear();
Response.ContentType = @"application\octet-stream";
System.IO.FileInfo file = new System.IO.FileInfo(Server.MapPath(FilePath));
Response.AddHeader("Content-Disposition", "attachment; filename=" + file.Name);
Response.AddHeader("Content-Length", file.Length.ToString());
Response.ContentType = "application/octet-stream";
Response.WriteFile(file.FullName);
Response.Flush();
}
Hope it helps!
--Amit