Avatar of Ed
Ed
Flag 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

ASP.NETVisual Basic.NET.NET Programming

Avatar of undefined
Last Comment
Ed

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Prakash Samariya

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Ed

ASKER
Perfect, you are the Master....
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck