Note that there are some explanatory texts on larger screens.

plurals
  1. POExport Gridview to Excel but the whole aspx page exported instead
    primarykey
    data
    text
    <p>This is the code. But the Excel file is showing the whole aspx page instead of the gridview.</p> <pre><code>Protected Sub btnExport_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnExport.Click Try Response.Clear() Response.AddHeader("content-disposition", ("attachment;filename=HotelList_" &amp; DateTime.Now.Year.ToString().Trim()) + DateTime.Now.Month.ToString().Trim().PadLeft(2, Convert.ToChar("0")) + DateTime.Now.Day.ToString().Trim().PadLeft(2, Convert.ToChar("0")) &amp; ".xls") Response.Charset = "" Response.Cache.SetCacheability(HttpCacheability.NoCache) Response.ContentType = "application/vnd.ms-excel" Dim stringWrite As New System.IO.StringWriter Dim htmlWrite As System.Web.UI.HtmlTextWriter = New HtmlTextWriter(stringWrite) Dim selctedCountry As String = ddlCountry.SelectedItem.Text.ToString() Dim selCity As String = ddlCity.SelectedItem.Text.ToString() htmlWrite.Write("&lt;div style='PADDING-RIGHT: 5px; PADDING-LEFT: 5px; PADDING-BOTTOM: 0px; PADDING-TOP: 0px'&gt;&lt;h3&gt;HOTEL LIST&lt;/h3&gt;") htmlWrite.Write("&lt;table&gt;&lt;tr&gt;&lt;td colspan='2'&gt; Country : " &amp; selctedCountry &amp; " &lt;/td&gt;&lt;/tr&gt;") htmlWrite.Write("&lt;table&gt;&lt;tr&gt;&lt;td colspan='2'&gt; City : " &amp; selCity &amp; " &lt;/td&gt;&lt;/tr&gt;") gvHotelMarkup.RenderControl(htmlWrite) htmlWrite.Write("&lt;/div&gt;") Response.Write(stringWrite.ToString()) Response.End() Catch ex As Exception lblErrMessage.Message = ex.Message() End Try End Sub </code></pre> <p>Any idea how to solve this? Thanks in advance.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload