473,508 Members | 2,403 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 1206
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
4722
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",...
4
13475
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. ...
0
1836
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 &...
2
2692
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
7224
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,...
0
7323
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,...
1
7038
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...
0
7493
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...
0
5625
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,...
1
5049
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...
0
3192
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...
0
3180
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
763
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.