Protected Sub btnsndexl_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnsndexl.Click
If gdhidden.Rows.Count > 0 Then
ExportGridView()
Else
ScriptManager.RegisterClientScriptBlock(btnsndexl, Me.GetType(), "MyScript", "alert('No Record Found');", True)
End If
End Sub
Private Sub ExportGridView()
gdhidden.Visible = True
Dim attachment As String = "attachment; filename=Report.xls"
Response.ClearContent()
Response.AddHeader("content-disposition", attachment)
Response.ContentType = "application/ms-excel"
Dim sw As New IO.StringWriter
Dim htw As New UI.HtmlTextWriter(sw)
gdhidden.RenderControl(htw)
Response.Write(sw.ToString())
Response.End()
gdhidden.Visible = False
End Sub