Hi i have tried the following code on my button click event but it shows an error as
Control 'ctl00_ContentPlaceHolder1_grdsalarydetail' of type 'GridView' must be placed inside a form tag with runat=server. i have tried the same logic of code i asp.net with vb which works after adding an overrides method as
Response.Clear();
Response.AddHeader("Content-disposition", "Attachmen;filename=reports.xlsx");
StringWriter StringWriter = new System.IO.StringWriter();
HtmlTextWriter HtmlTextWriter = new HtmlTextWriter(StringWriter);
grdsalarydetail.RenderControl(HtmlTextWriter);
Response.Write(StringWriter.ToString());
Response.End();
but can any one explain in csharp how can i use the same code as i am not getting the correct logic of override method in csharp
<b><pre lang="vb">Public Overrides Sub VerifyRenderingInServerForm(ByVal control As System.Web.UI.Control)
'MyBase.VerifyRenderingInServerForm(control)
End Sub</pre>
</b>