Hi,
I am new to telerik controls. It seems really good an I have been evaluating it for use in a project I am working on. The client is really impressed with the look/feel/design. But before I can get him to purchase it I need to be sure I can achieve all the results needed. There is only 1 problem, I am unable to get downloads from a grid working. Below is the code I am using to run the download command. The problem is the choose location dialogue box never appear when I click the download link. I need to mention here that the download link is in a nested grid (grid inside a master grid). Could this be the problem? How do I overcome this?
//Code for inner grid. The event is grid_itemcommand()
void gvReceipt_ItemCommand(object source, GridCommandEventArgs e)
{
if (e.CommandName == "Download")
{
var ExpHeader_ID = (int)((GridEditableItem)e.Item).GetDataKeyValue("ExpenseHeaderID");
Int32 ExpID = Convert.ToInt32(ExpHeader_ID);
ExpHeaderIdReceipt = ExpID;
GridDataItem dataItem = (GridDataItem)e.Item;
Label lblImgeName = (Label)dataItem.FindControl("lblImage");
string strRequest = lblImgeName.Text;
if (!string.IsNullOrEmpty(strRequest))
{
string path = Server.MapPath(Manage_FilePaths.HeaderExpImagesRootPath_Original
+ strRequest);
System.IO.FileInfo file = new System.IO.FileInfo(path);
if (file.Exists)
{
Response.Clear();
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.End();
}
else
{
Response.Write("This file does not exist.");
}
}
else
{
ScriptManager.RegisterStartupScript(this.updGrids, typeof(string), "alert", "<script>alert('Please provide a file to download!');</script>", false);
}
}
}
I am new to telerik controls. It seems really good an I have been evaluating it for use in a project I am working on. The client is really impressed with the look/feel/design. But before I can get him to purchase it I need to be sure I can achieve all the results needed. There is only 1 problem, I am unable to get downloads from a grid working. Below is the code I am using to run the download command. The problem is the choose location dialogue box never appear when I click the download link. I need to mention here that the download link is in a nested grid (grid inside a master grid). Could this be the problem? How do I overcome this?
//Code for inner grid. The event is grid_itemcommand()
void gvReceipt_ItemCommand(object source, GridCommandEventArgs e)
{
if (e.CommandName == "Download")
{
var ExpHeader_ID = (int)((GridEditableItem)e.Item).GetDataKeyValue("ExpenseHeaderID");
Int32 ExpID = Convert.ToInt32(ExpHeader_ID);
ExpHeaderIdReceipt = ExpID;
GridDataItem dataItem = (GridDataItem)e.Item;
Label lblImgeName = (Label)dataItem.FindControl("lblImage");
string strRequest = lblImgeName.Text;
if (!string.IsNullOrEmpty(strRequest))
{
string path = Server.MapPath(Manage_FilePaths.HeaderExpImagesRootPath_Original
+ strRequest);
System.IO.FileInfo file = new System.IO.FileInfo(path);
if (file.Exists)
{
Response.Clear();
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.End();
}
else
{
Response.Write("This file does not exist.");
}
}
else
{
ScriptManager.RegisterStartupScript(this.updGrids, typeof(string), "alert", "<script>alert('Please provide a file to download!');</script>", false);
}
}
}