Hello community
I'm having problems in downloading files from a grid, i saw some solutions, all very similar, and but none solve my problem, i guess there must be some small mistake from my own. Can you help me?
I'm using layers architecture in Telerik ASP.NET ajax
//ACSX User Control
//Acsx.cs
protected void gvTimesheets_ItemCommand(object sender, Telerik.Web.UI.GridCommandEventArgs e)
{
if (e.CommandName == "download_file")
{
GridDataItem item = (GridDataItem)e.Item;
var itemIndex = e.CommandArgument;
}
protected void link1_Click(object sender, EventArgs e)
{
var model = listagembll.GetFileByID(ID);
if (model.FileContent != null)
{
Response.Clear();
Response.ClearContent();
Response.ClearHeaders();
Response.AddHeader("Content-Type", "Application/octet-stream");
Response.AddHeader("Content-Length", model.FileContent.Length.ToString());
Response.AddHeader("Content-Disposition", "inline; ficheiro=" + model.Ficheiro + model.FileTipo); // inline ou attachment
Response.BinaryWrite(model.FileContent);
Response.Flush();
Response.End();
}
}
}
//BLL GetFilebyID
public ListagemTimesheet GetFileByID(int ID)
{
using (GestaoProjectosEntities lt = new GestaoProjectosEntities())
{
return lt.ListagemTimesheets.FirstOrDefault(a => a.ID == ID);
}
}
Harlem 98Posted Nov 5, 2021, 11:41 AM
Sachin SinghPosted Nov 5, 2021, 10:18 AM
Harlem 98Posted Nov 4, 2021, 4:11 PM
I can´t post my full anwser because of casharpcorner error, with some changes the approach as worked.
Nevertheless, now i have big new issues
The file downloads, only with its name as content, and the page keeps loading infinitily after the download's finished.
Sachin SinghPosted Nov 4, 2021, 9:31 AM