Export only Gridview Data to Excel format in Asp.net C#
<p>In my page I have two textbox controls, where I am gating the date from the Calendar Extender &amp; in the export to excel Button I am going to export the Gridview data to excel sheet.
When I am gating the excel sheet its show the the textbox &amp; button also from which i am export the excel Sheet.</p>

<p>I have written the export code in the Export Button.
Like:-</p>

<pre><code>    protected void Export_to_Excel_Click(object sender, EventArgs e)
    {
        try
        {

            Response.ClearContent();
            Response.Buffer = true;
            Response.AddHeader("content-disposition", string.Format("attachment; filename={0}", "Customers.xls"));
            Response.ContentType = "application/ms-excel";
            StringWriter sw = new StringWriter();
            HtmlTextWriter htw = new HtmlTextWriter(sw);
            Grd_MidData.AllowPaging = false;
            bindgriddata();
            //Change the Header Row back to white color
            Grd_MidData.HeaderRow.Style.Add("background-color", "#FFFFFF");
            //Applying stlye to gridview header cells
            for (int i = 0; i &lt; Grd_MidData.HeaderRow.Cells.Count; i++)
            {
                Grd_MidData.HeaderRow.Cells[i].Style.Add("background-color", "#df5015");
            }
            Grd_MidData.RenderControl(htw);
            Response.Write(sw.ToString());
            Response.Flush();
        }
        catch (Exception ee)
        {

        }
    }
</code></pre>

<p>When I am gating the excel sheet it shows the gridview data along with the two text box &amp; the button from where I am doing the filtering.</p>

<p>So any one suggest me, How to show only the gridview data but not show the Textbox &amp; button on the excel sheet.</p>