Click事件
Response.ClearContent(); Response.AddHeader("content-disposition", "attachment; filename=MyExcelFile.xls"); Response.ContentType = "application/excel"; StringWriter sw = new StringWriter(); HtmlTextWriter htw = new HtmlTextWriter(sw); gvUsers.RenderControl(htw); Response.Write(sw.ToString()); Response.End(); |
如果不写这个重载,将报错:控件放入runat=server 中...
public override void VerifyRenderingInServerForm(Control control) { } |
完成!!
详细讲解: