データグリッドをExcelファイルにエクスポートしようとしています。asp:BoundColumnは正しく変換されますが、リンクボタンまたはイメージボタンのあるテンプレート列は変換できません。それらのセルは空のセルとして変換されます。
コントロールをExcelにエクスポートするコードは次のとおりです。
Public Shared Sub Export(ByVal Mime As String, ByVal Filename As String, ByVal Response As HttpResponse, ByVal Control As Control)
Dim stringWrite As New System.IO.StringWriter()
Dim htmlWrite As New System.Web.UI.HtmlTextWriter(stringWrite)
Response.Clear()
Response.Buffer = True
Response.Charset = String.Empty
Response.ContentType = Mime
Response.AddHeader("Content-Disposition", "filename=" & Filename)
Control.RenderControl(htmlWrite)
Response.Write("<!DOCTYPE html PUBLIC ""-//W3C//DTD XHTML 1.0 Transitional//EN"" ""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd""><html xmlns=""http://www.w3.org/1999/xhtml""><head id=""Head1"" runat=""server""><meta http-equiv=""content-type"" content=""text-html; charset=utf-8""></head><body>" & stringWrite.ToString & "</body></html>")
Response.End()
End Sub
問題はどこにあるのでしょうか?何か案は?前もって感謝します。