Link to home
Start Free TrialLog in
Avatar of Ed
EdFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Add session name to Response.Add header filename

|The below code outputs my gridview to excel.

This works fine but I'd like to know how can I add my session variable to the filename.

E.g

Session("Name") gets added to  filename=CaseloadOutput.xls

so it might say filename=Edj_CaseloadOutput.xls



 
  Protected Sub gtnOExcelOutput_Click(sender As Object, e As EventArgs)
        Response.ClearContent()
        Response.AddHeader("content-disposition", "attachment; filename=CaseloadOutput.xls")
        Response.ContentType = "application/excel"
        Dim sw As New System.IO.StringWriter()
        Dim htw As New HtmlTextWriter(sw)
        gvCaseloadExcel.RenderControl(htw)
        Response.Write(sw.ToString())
        Response.[End]()
    End Sub

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Prakash Samariya
Prakash Samariya
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Ed

ASKER

Perfect, you are the Master....