Export GridView to Excel

See code below.  I have the following code to write my contents of my gridview to excel.  In one column I am sometimes getting a funny character and I'm not sure why or how to get rid of it.  I could intercept it in the rowdatabound event?  How would I find and replace this character.  Any ideas on what would cause this?


'Write out what is in the Gridview
        Response.Buffer = True
        Response.ContentType = "application/vnd.ms-excel"
        GridView1.Caption = "Grade Groups"
        Response.AddHeader("Content-Disposition", "attachment; filename=" + GridView1.Caption + ".xls")
        Response.Charset = ""
        Me.EnableViewState = False
        Dim oStringWriter As New System.IO.StringWriter
        Dim oHtmlTextWriter As New System.Web.UI.HtmlTextWriter(oStringWriter)
        GridView1.Caption = ""
        GridView1.FooterRow.Visible = False


Open in new window

Who is Participating?
Bob LearnedCommented:
It is difficult to know for certain, but that almost looks like a character set conversion problem.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.