Reputation: 3
I'm trying to export data however it only extract the data in current paging. And I need to go to another paging to download another. Is there any where to download all data in the source?
Below is my aspx code:
<asp:datagrid id="dgAmount" Visible=false runat="server" CssClass="item01Nxx08" Width="100%" CellPadding="3" BorderColor="#DEDFDE" BorderStyle="None" PageSize="50" AutoGenerateColumns="False" AllowSorting="True" AllowPaging="True" BackColor="White" BorderWidth="1px" GridLines="Vertical" ForeColor="Black"> <asp:BoundColumn DataField="No" SortExpression="No" HeaderText="No" visible="False"></asp:BoundColumn> <asp:BoundColumn DataField="Action" SortExpression="Action" HeaderText="Action"></asp:BoundColumn> <asp:BoundColumn DataField="AppName" SortExpression="AppName" HeaderText="Approver Name"></asp:BoundColumn> <asp:BoundColumn DataField="MIAmount" SortExpression="MIAmount" HeaderText="MI Amount"></asp:BoundColumn> <asp:BoundColumn DataField="By" SortExpression="By" HeaderText="By"> </asp:BoundColumn> <asp:BoundColumn DataField="Date" SortExpression="Date" HeaderText="Date"> </asp:BoundColumn> </asp:DataGrid>
And below is my vb code: System.Web.HttpContext.Current.Response.Clear() System.Web.HttpContext.Current.Response.Buffer = True System.Web.HttpContext.Current.Response.AddHeader("Content-Disposition", "filename=" & fileName & ".xls;") System.Web.HttpContext.Current.Response.ContentType = "application/vnd.ms-excel" System.Web.HttpContext.Current.Response.Charset = ""
'set the response mime type for excel
'create a string writer
Dim stringWrite As System.IO.StringWriter = New System.IO.StringWriter
'create an htmltextwriter which uses the stringwriter
Dim htmlWrite As System.Web.UI.HtmlTextWriter = New System.Web.UI.HtmlTextWriter(stringWrite)
htmlWrite.WriteLine("<b><u>" & header & "</u></b><br /><br />")
'instantiate a datagrid
Dim dg As New DataGrid()
Dim dt As New DataTable, dr As DataRow
dt.Columns.Add(New DataColumn("No", GetType(Integer)))
dt.Columns.Add(New DataColumn("Action", GetType(String)))
dt.Columns.Add(New DataColumn("Approver Name", GetType(String)))
dt.Columns.Add(New DataColumn("MI Amount", GetType(String)))
dt.Columns.Add(New DataColumn("By", GetType(String)))
dt.Columns.Add(New DataColumn("Date", GetType(String)))
Dim tempDg As DataGrid = dgAmount
For Each item As DataGridItem In tempDg.Items
dr = dt.NewRow()
dr("No") = item.Cells(0).Text
dr("Action") = item.Cells(1).Text
dr("Approver Name") = item.Cells(2).Text
dr("MI Amount") = item.Cells(3).Text
dr("By") = item.Cells(4).Text
dr("Date") = item.Cells(5).Text
dt.Rows.Add(dr)
Next
dg.DataSource = dt
dg.DataBind()
dg.EnableViewState = False
dg.GridLines = GridLines.None
dg.HeaderStyle.Font.Name = "Verdana"
dg.HeaderStyle.Font.Size = 8
dg.HeaderStyle.Font.Bold = True
dg.HeaderStyle.HorizontalAlign = HorizontalAlign.Center
dg.HeaderStyle.ForeColor = Drawing.Color.White
dg.HeaderStyle.BackColor = Drawing.Color.Black
dg.ItemStyle.Font.Name = "Verdana"
dg.ItemStyle.Font.Size = 8
dg.ItemStyle.VerticalAlign = VerticalAlign.Top
'bind the modified datagrid
'tell the datagrid to render itself to our htmltextwriter
dg.RenderControl(htmlWrite)
'output the html
System.Web.HttpContext.Current.Response.Write(stringWrite.ToString)
System.Web.HttpContext.Current.Response.End()
System.Web.HttpContext.Current.Response.Redirect("")
Upvotes: 0
Views: 186