I'm using radgrid nestedviewttemplate to show the details of a product on row expand.I also have a linkbutton in my nestedview template which when clicked downloads the file.My code that i use for download works outside radgrid but when included in Nestedviewtemplate it fails to download.here's my code.
<telerik:RadGrid ID="loggedInUserOwnResourcesRadGrid" AutoGenerateColumns="false">
<MasterTableView AutoGenerateColumns="false">
<Columns>
<telerik:GridTemplateColumn DataField=" Name">
<HeaderTemplate><asp:LinkButton ID="LinkButtonForTitleOfGridViewColumn"
runat="server" CommandName="Sort" CommandArgument="Name">Resource Name</asp:LinkButton>
</HeaderTemplate>
<ItemTemplate>
<asp:LinkButton ID="LinkButtonOfAParticularName" runat="server" Text='<%# Eval(" Name")%>'></asp:LinkButton>
</ItemTemplate>
</telerik:GridTemplateColumn>
</Columns>
<NestedViewSettings >
<ParentTableRelation>
<telerik:GridRelationFields DetailKeyField="ID" MasterKeyField="ID"/>
</ParentTableRelation>
</NestedViewSettings>
<NestedViewTemplate>
<asp:Panel ID="NestedViewPanel" runat="server">
<div >
<fieldset >
<legend ><b>Detail Info on Resource : <%#Eval("Name") %></b>
</legend>
Download File :
<asp:LinkButton ID="filenamelinkbutton" Text='<%# Eval("Filename")%>' CommandArgument='<%#
Eval("PathToFile")%>' OnCommand="filenamelinkbutton_Clicked" CommandName="filenamelinkbutton_Clicked"
runat="server" ToolTip="Click To Download" ForeColor="Blue" ></asp:LinkButton>
</fieldset>
</div>
</asp:Panel>
</NestedViewTemplate>
</MasterTableView>
</telerik:RadGrid>
protected void filenamelinkbutton_Clicked(object sender, CommandEventArgs e)
{
string downloadfilename = e.CommandArgument.ToString();
try
{
FileInfo resourcefilepathusingfileinfo = new FileInfo("~/" + downloadfilename);
string filename = resourcefilepathusingfileinfo.Name;
Response.ContentType = "application/download";
Response.AppendHeader("Content-Disposition", "attachment;filename=" + filename);
Response.TransmitFile(Server.MapPath("~/" + "ClientBin/" + "Uploads/" + filename));
HttpContext.Current.ApplicationInstance.CompleteRequest();
// Response.End();
}
catch (Exception ex)
{
}
}