473,660 Members | 2,445 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

export ALL datagrid rows to excel (not just current page)?

Any way to get it to export ALL rows? I tried playing with the
PageSize and AllowPaging = False before exporting, but no luck.

<snip>

Public Sub btnExport_OnCli ck(ByVal sender As Object, ByVal e As
EventArgs)
Response.Conten tType = "applicatio n/vnd.ms-excel"
Response.AddHea der("Content-Disposition", "inline;filenam e=" &
gstrTableName & ".xls")
Response.Charse t = ""
Me.EnableViewSt ate = False
ClearControls(d gParent)
Dim tw As New System.IO.Strin gWriter
Dim hw As New System.Web.UI.H tmlTextWriter(t w)
' Get the HTML for the control.
dgParent.PageSi ze =
gobjDataSet.Tab les(gstrTableNa me).Rows.Count
dgParent.Render Control(hw)
' Write the HTML back to the browser.
Response.Write( tw.ToString())
' End the response.
Response.End()
End Sub
Private Sub ClearControls(B yVal control As Control)
Dim i As Integer
For i = control.Control s.Count - 1 To 0 Step -1
ClearControls(c ontrol.Controls (i))
Next
If Not TypeOf control Is TableCell Then
If Not (control.GetTyp e().GetProperty ("SelectedItem" ) Is
Nothing) Then
Dim literal As New LiteralControl
control.Parent. Controls.Add(li teral)
Try
literal.Text =
CStr(control.Ge tType().GetProp erty("SelectedI tem").GetValue( control,
Nothing))
Catch
End Try
control.Parent. Controls.Remove (control)
Else
If Not (control.GetTyp e().GetProperty ("Text") Is
Nothing) Then
Dim literal As New LiteralControl
control.Parent. Controls.Add(li teral)
literal.Text =
CStr(control.Ge tType().GetProp erty("Text").Ge tValue(control, Nothing))
control.Parent. Controls.Remove (control)
End If
End If
End If
End Sub
</snip>

Nov 19 '05 #1
1 1112
Anyone?

Nov 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
403
by: Diego | last post by:
Hi, I have a ASP.NET application and i'm interested in reporting in excel format. I read a good artile written by Steve C. Orr that gave me info about exporting to excel. http://www.aspnetpro.com/NewsletterArticle/2003/09/asp200309so_l/asp200309so_l.asp Basically the app shows the report in a datagrid and on the OnClick event of
3
1662
by: mattdaddym | last post by:
Hi all, I have been using the following code to export my datagrids to excel for quite some time. Very simple and very effective. <code> Sub btnExcelExport_Click ( s As Object, e As EventArgs ) Response.Clear() Response.AddHeader("content-disposition", "attachment;filename=FileName.xls")
5
2322
by: The Colonel | last post by:
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)
6
3723
by: Sridhar | last post by:
Hi, I have to export data inside the datagrid into an excel worksheet. I have to do this on button click event. I am trying to do like this. First get the DataTable from the datagrid and iterate through each row to get the data. I am not able to get the DataTable from the datagrid. How could I do that? I tried like this but it is not working Dim dt as DataTable = CType(datagrid1.DataSource, DataTable)
4
3936
by: Frank | last post by:
Hello All, I ham using VS.NET 2003. Have followed instructions from http://gridviewguy.com/ArticleDetails.aspx?articleID=26 along with several other articles to no avail. I am pulling my hair out at this point. What I have is this : Members.aspx file:
4
2192
by: Amirallia | last post by:
Hello Here's my code to export a datagrid to Exel : Response.Clear() Response.Buffer = True Response.ContentType = "application/vnd.ms-excel" Response.Charset = "" Dim monStringWriter As StringWriter = New StringWriter Dim monHtmlTextWriter As HtmlTextWriter = New HtmlTextWriter(monStringWriter)
0
2738
by: Y2KPRABU | last post by:
for exporting to excel just call the function below in sample code and pass the page object from an aspx and the aspx page contents are rendered in excel.. make control.visible = false if you dont want those controls to be exported to excel. the same function can be overloaded to pass say a datagrid (in most search screens we need results only)also.
2
1768
by: leena13 | last post by:
Hi, The number of rows in the datagrid on my page are approx. around 14130. When I click on the button that exports the records to excel sheet, the page goes blank (I observed that none of the events are firing). To confirm this is happening because of the no. of rows, I modified the SP to retrieve around only 100 records. I could export these records in the datagrid successfully. I am aware that the max no of rows to export to excel...
1
6682
by: DennisBetten | last post by:
First of all, I need to give some credit to Mahesh Chand for providing me with an excellent basis to export data to excel. What does this code do: As the title says, this code is capable of extracting all tables and it's data from any given database! I was searching the net for a program like this, but I didn't come accross any (free) versions. So I decided to write it myself. To get this code to work, you need to add a reference to...
0
8428
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8341
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8851
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8542
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8630
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7362
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5650
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
2760
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1740
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.