473,662 Members | 2,406 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to take the backup of gridview data.

83 New Member
Hii Experts,

I've a query about gridview.

My requirement is, in one of my webpages there is one gridview which is displaying the participants data like name ,emilid and so on.if the user wants he can edit the values and update the same in the database also..but before he is commiting the changes to the database i wanna to take the back up of those pervious values(before modifying ).

i tried of reading the cell values in the RowDataBound event of the gridview but it didn work for me ..getting all as null values only.

Can somebody tell me how can i do this.

Thank you
Rgds,
BTR.
Feb 3 '09 #1
1 1212
shrimant
48 New Member
Modify the following piece of code to fit your requirement, it saves the Gridview contents to an Excel. Id you have sorting or Paging or other customization.. .as you see below you need to turn them off before you could save the entire content. There is also an restriction of Max 65536 rows...due to excel.

Expand|Select|Wrap|Line Numbers
  1. Protected Sub ImageButton2_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles ImageButton2.Click
  2.         If GridView1.Rows.Count.ToString + 1 < 65536 Then
  3.             GridView1.AllowPaging = False
  4.             GridView1.AllowSorting = False
  5.             GridView1.DataBind()
  6.             Dim tw As New StringWriter()
  7.             Dim hw As New System.Web.UI.HtmlTextWriter(tw)
  8.             Dim frm As HtmlForm = New HtmlForm()
  9.             Response.ContentType = "application/vnd.ms-excel"
  10.             Response.AddHeader("content-disposition", "attachment;filename=" & "COP_Review_" & FormatDateTime(Now, DateFormat.ShortDate).Replace("/", "_") & ".xls")
  11.             Response.Charset = ""
  12.             EnableViewState = False
  13.             Controls.Add(frm)
  14.             frm.Controls.Add(GridView1)
  15.             frm.RenderControl(hw)
  16.             Response.Write(tw.ToString())
  17.             Response.End()
  18.             GridView1.AllowPaging = True
  19.             GridView1.AllowSorting = True
  20.             GridView1.DataBind()
  21.         Else
  22.             MsgBox("Too many rows - Export to Excel not possible")
  23.         End If
  24.     End Sub
Feb 17 '09 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
4743
by: alex | last post by:
Hi ! I couldn't make backups with our new system using db2 8.2. Every time I trigger a backup I get this error message: BACKUP DATABASE EBUERO2 ONLINE TO "/raid/backup/ebuero2/part1", "/raid/backup/ebuero2/part10", "/raid/backup/ebuero2/part11", "/raid/backup/ebuero2/part12", "/raid/backup/ebuero2/part13", "/raid/backup/ebuero2/part14", "/raid/backup/ebuero2/part15", "/raid/backup/ebuero2/part16", "/raid/backup/ebuero2/part17",
4
13484
by: Jim Katz | last post by:
I have an application that updates a strongly typed data set at run time. I'd like to dynamically create a table that connects to a run time data table. For displaying the data, this works well. I just set the GridView.DataSource once, and call DataBind(); I'd like to drive the application from the GridView control, by including command buttons that allow editing of the data. Starting out simple, I have a DataTable with a boolean...
0
1845
by: sajijkumar | last post by:
How can I take backup of the database to flash drive. I used a Dir and Drive list box controls to select the perticular dir, and Wrote the code, Shell "command.com /c copy " & App.Path & "\AlkushDB.mdb " & Drive1.Drive, vbNormalFocus but it is not working. Now I changed my DB to SQL. I must take the backup of this sql database also. (Restore also.)
2
2701
by: Abhijit Taur | last post by:
hi i am using vb.net2005 i want to take daily backup from application and attach that daily backup if any data loss
0
8343
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,...
1
8545
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,...
1
6185
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5653
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();...
0
4179
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4347
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2762
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
1992
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1747
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.