El ejemplo extrae el codigo html que asp net genera.
Código:
en donde la variable str se almacena el string del codigo html del datagrid que es mostrado en el cliente.Dim cnn As New SqlConnection(AppSettings("ActivitiesConnection")) Dim adap As New SqlDataAdapter("select * from actividades", cnn) Dim dtable As New DataTable adap.Fill(dtable) Me.DataGrid1.DataSource = dtable Me.DataGrid1.DataBind() Dim str As String Dim strbuild As System.Text.StringBuilder Dim strWriter, strWriter2 As System.IO.StringWriter strWriter = New System.IO.StringWriter strWriter2 = New System.IO.StringWriter Dim html As New System.Web.UI.HtmlTextWriter(strWriter) 'me.datos = control que contiene todo el html que se quiere obtener Me.DataGrid1.RenderControl(html) strWriter2 = html.InnerWriter strbuild = strWriter2.GetStringBuilder() 'str contiene todo el html del control str = strbuild.ToString()
Salu2