0

I getting an error that one when click on the Export Button in the show shows the data of GridView Along with PageIndexing NUmbers also

protected void btnexcel_Click(object sender, EventArgs e)
    {       
        Response.Clear();
        Response.AddHeader("content-disposition", "attachment;filename=Emp.xls");
        Response.ContentType = "application/vnd.ms-excel";
        StringWriter sw = new StringWriter();
        HtmlTextWriter htw = new HtmlTextWriter(sw);
        GridView1.RenderControl(htw);
        Response.Write(sw.ToString());
        Response.End();
    }
2
Contributors
2
Replies
3
Views
6 Years
Discussion Span
Last Post by umamahesh2020
0

Can you please let us know what the error is coming up when you are exporting data to excel file ?

I getting an error that one when click on the Export Button in the show shows the data of GridView Along with PageIndexing NUmbers also

protected void btnexcel_Click(object sender, EventArgs e)
    {       
        Response.Clear();
        Response.AddHeader("content-disposition", "attachment;filename=Emp.xls");
        Response.ContentType = "application/vnd.ms-excel";
        StringWriter sw = new StringWriter();
        HtmlTextWriter htw = new HtmlTextWriter(sw);
        GridView1.RenderControl(htw);
        Response.Write(sw.ToString());
        Response.End();
    }
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.