Wednesday, November 28, 2012

Display a file in NewPage and export a file to Excel.

Display a file on Link Button Click.


protected void linkbtnFile_Click(object sender, EventArgs e)
    {
        string link =  Server.MapPath(".") + "\\\\" +;
        Response.ContentType = "application/"+linkbtnFile.Text.Substring(linkbtnFile.Text.IndexOf('.')+1);
        Response.AppendHeader("Content-Disposition", "attachment; filename=" + link);
        Response.TransmitFile(link);
        Response.End();
    }


Export a File from Radgrid to Excel file.

protected void btnExport_Click(object sender, EventArgs e)
    {
        RadGrid1.MasterTableView.ExportToExcel();
        RadGrid1.ExportSettings.ExportOnlyData = true;
        RadGrid1.ExportSettings.IgnorePaging = true;
        RadGrid1.ExportSettings.OpenInNewWindow = true;
    }

No comments:

Post a Comment

Wednesday, November 28, 2012

Display a file in NewPage and export a file to Excel.

Display a file on Link Button Click.


protected void linkbtnFile_Click(object sender, EventArgs e)
    {
        string link =  Server.MapPath(".") + "\\\\" +;
        Response.ContentType = "application/"+linkbtnFile.Text.Substring(linkbtnFile.Text.IndexOf('.')+1);
        Response.AppendHeader("Content-Disposition", "attachment; filename=" + link);
        Response.TransmitFile(link);
        Response.End();
    }


Export a File from Radgrid to Excel file.

protected void btnExport_Click(object sender, EventArgs e)
    {
        RadGrid1.MasterTableView.ExportToExcel();
        RadGrid1.ExportSettings.ExportOnlyData = true;
        RadGrid1.ExportSettings.IgnorePaging = true;
        RadGrid1.ExportSettings.OpenInNewWindow = true;
    }

No comments:

Post a Comment