[求助]关于EXCEL导出的问题
我的导出代码:后台:
Sub toexcel(ByVal ctrl As DataGrid)
HttpContext.Current.Response.AppendHeader("content-disposition", "attachment;filename=excel.xls")
HttpContext.Current.Response.Charset = "UTF-8"
HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.Default
HttpContext.Current.Response.ContentType = "application/ms-excel"
ctrl.Page.EnableViewState = False
Dim tw As New System.IO.StringWriter
Dim hw As New System.Web.UI.HtmlTextWriter(tw)
ctrl.RenderControl(hw)
HttpContext.Current.Response.Write(tw.ToString)
HttpContext.Current.Response.End()
End Sub
Private Sub btn_to_excel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_to_excel.Click
toexcel(Grid_ygxx_jb)
End Sub
但是运行时点击导出按钮时出错:类型“DataGridLinkButton”的控件“Grid_ygxx_jb__ctl3__ctl1”必须放在具有 runat=server 的窗体标记内。
错在哪里,请高手指点,谢谢!