Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Try this out, it's a touch simpler than Brendans but not as 'feature rich': </p> <pre><code> Protected Sub btnExport_Click(ByVal sender As Object, ByVal e As System.EventArgs) 'Export to excel Response.Clear() Response.Buffer = True Response.ContentType = "application/vnd.ms-excel" Response.Charset = "" Me.EnableViewState = False Dim oStringWriter As System.IO.StringWriter = New System.IO.StringWriter Dim oHtmlTextWriter As System.Web.UI.HtmlTextWriter = New System.Web.UI.HtmlTextWriter(oStringWriter) Me.ClearControls(gvSearchTerms) gvSearchTerms.RenderControl(oHtmlTextWriter) Response.Write(oStringWriter.ToString) Response.End() End Sub Private Sub ClearControls(ByVal control As Control) Dim i As Integer = (control.Controls.Count - 1) Do While (i &gt;= 0) ClearControls(control.Controls(i)) i = (i - 1) Loop If Not (TypeOf control Is TableCell) Then If (Not (control.GetType.GetProperty("SelectedItem")) Is Nothing) Then Dim literal As LiteralControl = New LiteralControl control.Parent.Controls.Add(literal) Try literal.Text = CType(control.GetType.GetProperty("SelectedItem").GetValue(control, Nothing), String) Catch ex As System.Exception End Try control.Parent.Controls.Remove(control) ElseIf (Not (control.GetType.GetProperty("Text")) Is Nothing) Then Dim literal As LiteralControl = New LiteralControl control.Parent.Controls.Add(literal) literal.Text = CType(control.GetType.GetProperty("Text").GetValue(control, Nothing), String) control.Parent.Controls.Remove(control) End If End If Return End Sub Public Overrides Sub VerifyRenderingInServerForm(ByVal control As Control) Return End Sub </code></pre>
 

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