Página Inicial > Hands on code > Pegando o html de um gridview

Pegando o html de um gridview

Muita gente com certeza já teve a necessidade de pegar o código html um gridview para por exemplo, enviar alguma informação por e-mail ou até imprimir um relatório. Enfim, segue uma pequena função (que pode e dever se melhorada) para a realização desta ação.

Public Function pegaHtmlGridView(ByVal gv As GridView) As String
        Dim tw As New System.IO.StringWriter
        Dim hw As New System.Web.UI.HtmlTextWriter(tw)
        Dim frm As System.Web.UI.HtmlControls.HtmlForm = New System.Web.UI.HtmlControls.HtmlForm()
        Controls.Add(frm)
        frm.Controls.Add(gv)
        frm.RenderControl(hw)
        Return tw.ToString
End Function
Author: Fernando Categories: Hands on code Tags:
  1. Nenhum comentário ainda.