T
The Colonel
I'm only getting current page. I've tried playing with the
PageSize and AllowPaging = False before exporting, but no luck. Here's
my code:
<snip>
Public Sub btnExport_OnClick(ByVal sender As Object, ByVal e As
EventArgs)
Response.ContentType = "application/vnd.ms-excel"
Response.AddHeader("Content-Disposition", "inline;filename=" &
gstrTableName & ".xls")
Response.Charset = ""
Me.EnableViewState = False
ClearControls(dgParent)
Dim tw As New System.IO.StringWriter
Dim hw As New System.Web.UI.HtmlTextWriter(tw)
' Get the HTML for the control.
dgParent.PageSize =
gobjDataSet.Tables(gstrTableName).Rows.Count
dgParent.RenderControl(hw)
' Write the HTML back to the browser.
Response.Write(tw.ToString())
' End the response.
Response.End()
End Sub
Private Sub ClearControls(ByVal control As Control)
Dim i As Integer
For i = control.Controls.Count - 1 To 0 Step -1
ClearControls(control.Controls(i))
Next
If Not TypeOf control Is TableCell Then
If Not (control.GetType().GetProperty("SelectedItem") Is
Nothing) Then
Dim literal As New LiteralControl
control.Parent.Controls.Add(literal)
Try
literal.Text =
CStr(control.GetType().GetProperty("SelectedItem").GetValue(control,
Nothing))
Catch
End Try
control.Parent.Controls.Remove(control)
Else
If Not (control.GetType().GetProperty("Text") Is
Nothing) Then
Dim literal As New LiteralControl
control.Parent.Controls.Add(literal)
literal.Text =
CStr(control.GetType().GetProperty("Text").GetValue(control, Nothing))
control.Parent.Controls.Remove(control)
End If
End If
End If
End Sub
</snip>
PageSize and AllowPaging = False before exporting, but no luck. Here's
my code:
<snip>
Public Sub btnExport_OnClick(ByVal sender As Object, ByVal e As
EventArgs)
Response.ContentType = "application/vnd.ms-excel"
Response.AddHeader("Content-Disposition", "inline;filename=" &
gstrTableName & ".xls")
Response.Charset = ""
Me.EnableViewState = False
ClearControls(dgParent)
Dim tw As New System.IO.StringWriter
Dim hw As New System.Web.UI.HtmlTextWriter(tw)
' Get the HTML for the control.
dgParent.PageSize =
gobjDataSet.Tables(gstrTableName).Rows.Count
dgParent.RenderControl(hw)
' Write the HTML back to the browser.
Response.Write(tw.ToString())
' End the response.
Response.End()
End Sub
Private Sub ClearControls(ByVal control As Control)
Dim i As Integer
For i = control.Controls.Count - 1 To 0 Step -1
ClearControls(control.Controls(i))
Next
If Not TypeOf control Is TableCell Then
If Not (control.GetType().GetProperty("SelectedItem") Is
Nothing) Then
Dim literal As New LiteralControl
control.Parent.Controls.Add(literal)
Try
literal.Text =
CStr(control.GetType().GetProperty("SelectedItem").GetValue(control,
Nothing))
Catch
End Try
control.Parent.Controls.Remove(control)
Else
If Not (control.GetType().GetProperty("Text") Is
Nothing) Then
Dim literal As New LiteralControl
control.Parent.Controls.Add(literal)
literal.Text =
CStr(control.GetType().GetProperty("Text").GetValue(control, Nothing))
control.Parent.Controls.Remove(control)
End If
End If
End If
End Sub
</snip>