473,702 Members | 2,601 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Tracking DataGrid changes

I have a DataGrid web control which I've dynamically populated with
template columns to be used for bulk-editting. Generally, all of the
columns are textbox and/or dropdownlist child controls.

Currently everything is working. I can find the updated rows/columns
by parsing the posted data collection against the DataGrid DataSource.
However, when there is a large amount of DataGridItems (rows) the
update processing can take a while.

What I'd like to do is to be able to, as changes are made, mark the
row as modified (in an invisible temaplate column which I'll add to
the DataGrid). That would provide a faster way to find modified rows
without the parsing.

My question:
Has anyone done this? What are some options? Because of viewstate size
concerns I'd prefer to go with a client-side (JavaScript) solution.

TIA
Glenn
Nov 17 '05 #1
4 5352
Hello Glenn,
If you are using Dataset, this functionality is already implemented. What
you can do is to use the method, DataSet.GetChan ges.
This method will get a copy of the Dataset containing all changes made to
it since it was last loaded, or since AcceptChanges
was called. The you will loop through every row and mark accordingly the
rows in the DataGrid. Another method to show
the modified information, is to have a new DataGrid of the updated
information.

For more information on GetChanges method refers to:
http://msdn.microsoft.com/library/de...us/cpref/html/
frlrfsystemdata datasetclassget changestopic.as p

Please let me know if you need more help on this.

Thanks,
Bassel Tabbara
Microsoft, ASP.NET

This posting is provided "AS IS", with no warranties, and confers no rights.

--------------------
| From: gl*********@kod ak.com (Glenn Owens)
| Newsgroups: microsoft.publi c.dotnet.framew ork.aspnet
| Subject: Tracking DataGrid changes
| Date: 2 Jul 2003 08:31:18 -0700
| Organization: http://groups.google.com/
| Lines: 20
| Message-ID: <3f************ **************@ posting.google. com>
| NNTP-Posting-Host: 165.170.128.66
| Content-Type: text/plain; charset=ISO-8859-1
| Content-Transfer-Encoding: 8bit
| X-Trace: posting.google. com 1057159878 25886 127.0.0.1 (2 Jul 2003
15:31:18 GMT)
| X-Complaints-To: gr**********@go ogle.com
| NNTP-Posting-Date: 2 Jul 2003 15:31:18 GMT
| Path:
cpmsftngxa09.ph x.gbl!TK2MSFTNG P08.phx.gbl!new sfeed00.sul.t-online.de!newsf ee
d01.sul.t-online.de!t-online.de!newsp eer1-gui.server.ntli .net!ntli.net!s n-xi
t-02!sn-xit-06!sn-xit-09!supernews.co m!postnews1.goo gle.com!not-for-mail
| Xref: cpmsftngxa09.ph x.gbl microsoft.publi c.dotnet.framew ork.aspnet:3175 1
| X-Tomcat-NG: microsoft.publi c.dotnet.framew ork.aspnet
|
| I have a DataGrid web control which I've dynamically populated with
| template columns to be used for bulk-editting. Generally, all of the
| columns are textbox and/or dropdownlist child controls.
|
| Currently everything is working. I can find the updated rows/columns
| by parsing the posted data collection against the DataGrid DataSource.
| However, when there is a large amount of DataGridItems (rows) the
| update processing can take a while.
|
| What I'd like to do is to be able to, as changes are made, mark the
| row as modified (in an invisible temaplate column which I'll add to
| the DataGrid). That would provide a faster way to find modified rows
| without the parsing.
|
| My question:
| Has anyone done this? What are some options? Because of viewstate size
| concerns I'd prefer to go with a client-side (JavaScript) solution.
|
| TIA
| Glenn
|
Nov 17 '05 #2

Bassel thanks for the reply.

The problem is not with the update. Once I can get the DataGrid changes
reflected in the DataTable (I'm currently using a DataView as the
DataGrid source) then updating the database is no issue. I'm using the
DataTable.GetCh anges to pull the modifed/inserted/deleted DataTable rows
for update.

Perhaps I wasn't clear enough...

For the bulk-edit, the DataGrid template columns are defined as the
ItemTemplate (not the EditTemplate) - this makes the DataGrid look like
a "spreadshee t". The User will update 1 or more columns on 1 or more
rows and will then click the Save button. At that point the Save
processing needs to extract the DataGrid data changes and place them
into the corresponding rows/columns of the Datatable (followed by an
Update/commit to the database).

Again, while this all works currently I'm looking for a quicker way to
migrate the DataGrid changes to the DataTable. I was assuming that some
client-side coding would be faster than parsing the post data collection
against the DataGrid data source (DataTable) on the server-side.

Bassel, if I'm missing soming fundamental (wouldn't be the first time)
please help me understand.

Thanks again!
Glenn
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 17 '05 #3
Hello Glenn,
I am not sure I totally understand the problem/scenario that you are
running into. I am not sure
what you are looking for exactly. If you are trying to get the changes on
the client side, this is
a totally different route and you might have something custom to build it.
If on the server, are you still looking to get changes?
Please can you illustrate with a sample code or be more specific?
I appreciate your cooperation so I can better help you.

Thanks,
Bassel Tabbara
Microsoft, ASP.NET

This posting is provided "AS IS", with no warranties, and confers no rights.

--------------------
| From: Glenn Owens <an*******@devd ex.com>
| References: <Mb************ **@cpmsftngxa09 .phx.gbl>
| X-Newsreader: AspNNTP 1.50 (ActionJackson. com)
| Subject: RE: Tracking DataGrid changes
| Mime-Version: 1.0
| Content-Type: multipart/mixed; boundary="----=_NextPart_000_ 44774108"
| Message-ID: <#z************ **@TK2MSFTNGP12 .phx.gbl>
| Newsgroups: microsoft.publi c.dotnet.framew ork.aspnet
| Date: Wed, 02 Jul 2003 15:15:18 -0700
| NNTP-Posting-Host: actionjackson13 3.dsl.frii.net 216.17.147.133
| Lines: 1
| Path: cpmsftngxa09.ph x.gbl!TK2MSFTNG P08.phx.gbl!TK2 MSFTNGP12.phx.g bl
| Xref: cpmsftngxa09.ph x.gbl microsoft.publi c.dotnet.framew ork.aspnet:3186 7
| X-Tomcat-NG: microsoft.publi c.dotnet.framew ork.aspnet
|
|
| Bassel thanks for the reply.
|
| The problem is not with the update. Once I can get the DataGrid changes
| reflected in the DataTable (I'm currently using a DataView as the
| DataGrid source) then updating the database is no issue. I'm using the
| DataTable.GetCh anges to pull the modifed/inserted/deleted DataTable rows
| for update.
|
| Perhaps I wasn't clear enough...
|
| For the bulk-edit, the DataGrid template columns are defined as the
| ItemTemplate (not the EditTemplate) - this makes the DataGrid look like
| a "spreadshee t". The User will update 1 or more columns on 1 or more
| rows and will then click the Save button. At that point the Save
| processing needs to extract the DataGrid data changes and place them
| into the corresponding rows/columns of the Datatable (followed by an
| Update/commit to the database).
|
| Again, while this all works currently I'm looking for a quicker way to
| migrate the DataGrid changes to the DataTable. I was assuming that some
| client-side coding would be faster than parsing the post data collection
| against the DataGrid data source (DataTable) on the server-side.
|
| Bassel, if I'm missing soming fundamental (wouldn't be the first time)
| please help me understand.
|
| Thanks again!
| Glenn
|
|
| *** Sent via Developersdex http://www.developersdex.com ***
| Don't just participate in USENET...get rewarded for it!
|
|
Nov 17 '05 #4
Yes, I'm looking for an alternative to the server-side code that I
currently have working. The code works (albeit not very fast) to
perform multi-column, multi-row updates within an edittable DataGrid.
My hope is that someone might suggest a JavaScript solution, with
example, (as I'm still coming up-to-speed with JavaScript) that will
identify modified rows in the DataGrid.

My thoughts around the client-side sollution:

o As the User modifies a column, in the DataGrid, a hidden column
(added by my server control) would be marked (i.e. a DataGrid
rowstatus column)

o When the User clicks the Save button for the DataGrid the code can
quickly find each modified DataGrid row and migrate the changes to the
DataTable for update.

The following is the server-side method that I'm currently using.

'============== =============== =============== =============== =============== =====
' Author: Glenn W. Owens
' Date: 7/7/2003
'
' Description:
' This method uses the PostBack data for the Fluid control to
populate,
' and update, any/all DDO data records which have been modified.
'
' Parameters:
' postCollection - when the user clicks the "Save" control button
the page
' collects the user-entered data into the Postback
data
' collection. This data collection becomes the
data source
' to update the existing DDO data record.
'
'============== =============== =============== =============== =============== =====

Private Sub ExecuteDataGrid Update(ByVal postCollection As
NameValueCollec tion)
Me.SetDefaultSe lect(ListSelect Key)

Ddo.Retrieve(Li stWhere) 'Re-retrieve the DDO data to update

Dim dc As DataColumn
Dim idx As Integer
Dim key As String
Dim newval As String
Dim oldval As String
Dim ctlOffset As Integer
Dim target As String = ":FluidListCont rol:_ctl"

'----------------------------------------------------------------------------
' Determine the control offset to use when referencing items from
the
' postCollection. The postCollection entries that we're
interested in look
' like:
'
' UniqueId:FluidL istControl:_ctl[offset]:_....
'
' We need the offset number from the first postCollection entry
that
' matches the pattern. The offset will be used to sychronize the
post data
' collection with the DataGrid items (rows).
'----------------------------------------------------------------------------

For idx = 0 To postCollection. Count - 1
key = postCollection. Keys(idx)

If key.IndexOf(tar get) > 0 Then
Dim start As Integer = key.IndexOf(":_ ctl")
Dim finish As Integer = key.LastIndexOf (":_")

If (start > 0) And (finish > start) Then
start += 5

ctlOffset = CInt(key.Substr ing(start, finish - start))

Exit For
End If
End If
Next

'----------------------------------------------------------------------------
' Parse through the DataGrid items (rows). Each modified table
cell
' DataGrid value will be subsequently set to the DDO DataTable.
When we're
' done parsing the DataGrid the updated DataTable rows will be
processed
' via the DDO Update method.
'----------------------------------------------------------------------------

For idx = 0 To Ddo.DataViewCou nt - 1
Dim items As New SetItemCollecti on()
Dim modified As Boolean = False

'-------------------------------------------------------------------------
' For each modified data item, for this Fluid control, add the
item to
' the Ddo SetItemCollecti on
'-------------------------------------------------------------------------

For Each dc In Ddo.ColumnColle ction
If (Not dc.ReadOnly) And _
(Ddo.DdoColumnP roperties.Visib le(dc.ColumnNam e)) And _
(Ddo.DdoColumnP roperties.EditE nabled(dc.Colum nName)) Then
key = UniqueID + _
":FluidListCont rol:_ctl" + (idx + ctlOffset).ToSt ring()
+ ":_"

If Ddo.IsDropDownC olumn(dc.Column Name) Then
Dim ctlidx As Integer = 0
Dim ddldc As DataColumn

'----------------------------------------------------------------
' Due to the way in which DropDownList controls (in
Table
' cells) are identified we need to find the
dropdownlist
' columns and count the ordinal position of the
control
' relative to preceeding dropdownlist, and invisible,
' controls. This ordinal index will be appended to
the static
' key (which references the postCollection data).
'----------------------------------------------------------------

For Each ddldc In Ddo.ColumnColle ction
If (Ddo.IsDropDown Column(ddldc.Co lumnName)) Or _
(Not
Ddo.DdoColumnPr operties.Visibl e(ddldc.ColumnN ame)) Then
ctlidx += 1

If ddldc.ColumnNam e = dc.ColumnName Then
Exit For
End If
End If
Next

key += "ctl" + ctlidx.ToString ()
Else
key += dc.ColumnName
End If

Try
'----------------------------------------------------------------
' If the current value in the post data collection
differs
' from the data retrieved by the DDO then the
row/data item
' has been modified. The Data item will be added to
the update
' collection.
'----------------------------------------------------------------

newval = postCollection( key).ToString()
oldval = Ddo.GetDataRow( idx)(dc.ColumnN ame).ToString()

If newval <> oldval Then
modified = True

items.Add(newva l, dc.ColumnName)
End If

Catch ex As System.Exceptio n

End Try
End If
Next

If modified Then
'----------------------------------------------------------------------
' Data item(s) were changed for this DataGrid row. Add the
changes
' to the DDO DataTable.
'----------------------------------------------------------------------

Ddo.SetItems(it ems, idx)

modified = False
End If
Next

'----------------------------------------------------------------------------
' Populate the new data record and add it to the DDO DataTable
'----------------------------------------------------------------------------

Try
Dim parms() As String = {Ddo.Update().T oString()}

Message = GetLocalizedTex t("FluidRecordU pdated", parms, parms(0)
+ _
" Record(s) Updated.")

Catch ex As System.Exceptio n
Dim parms() As String = {ex.Message}

ErrorMessage = GetLocalizedTex t("FluidUpdateE rror", parms, _
"Error Updating Record: " + ex.Message)
End Try
End Sub

ba*****@online. microsoft.com ("Bassel Tabbara [MSFT]") wrote in message news:<R$******* *******@cpmsftn gxa09.phx.gbl>. ..
Hello Glenn,
I am not sure I totally understand the problem/scenario that you are
running into. I am not sure
what you are looking for exactly. If you are trying to get the changes on
the client side, this is
a totally different route and you might have something custom to build it.
If on the server, are you still looking to get changes?
Please can you illustrate with a sample code or be more specific?
I appreciate your cooperation so I can better help you.

Thanks,
Bassel Tabbara
Microsoft, ASP.NET

This posting is provided "AS IS", with no warranties, and confers no rights.

--------------------
| From: Glenn Owens <an*******@devd ex.com>
| References: <Mb************ **@cpmsftngxa09 .phx.gbl>
| X-Newsreader: AspNNTP 1.50 (ActionJackson. com)
| Subject: RE: Tracking DataGrid changes
| Mime-Version: 1.0
| Content-Type: multipart/mixed; boundary="----=_NextPart_000_ 44774108"
| Message-ID: <#z************ **@TK2MSFTNGP12 .phx.gbl>
| Newsgroups: microsoft.publi c.dotnet.framew ork.aspnet
| Date: Wed, 02 Jul 2003 15:15:18 -0700
| NNTP-Posting-Host: actionjackson13 3.dsl.frii.net 216.17.147.133
| Lines: 1
| Path: cpmsftngxa09.ph x.gbl!TK2MSFTNG P08.phx.gbl!TK2 MSFTNGP12.phx.g bl
| Xref: cpmsftngxa09.ph x.gbl microsoft.publi c.dotnet.framew ork.aspnet:3186 7
| X-Tomcat-NG: microsoft.publi c.dotnet.framew ork.aspnet
|
|
| Bassel thanks for the reply.
|
| The problem is not with the update. Once I can get the DataGrid changes
| reflected in the DataTable (I'm currently using a DataView as the
| DataGrid source) then updating the database is no issue. I'm using the
| DataTable.GetCh anges to pull the modifed/inserted/deleted DataTable rows
| for update.
|
| Perhaps I wasn't clear enough...
|
| For the bulk-edit, the DataGrid template columns are defined as the
| ItemTemplate (not the EditTemplate) - this makes the DataGrid look like
| a "spreadshee t". The User will update 1 or more columns on 1 or more
| rows and will then click the Save button. At that point the Save
| processing needs to extract the DataGrid data changes and place them
| into the corresponding rows/columns of the Datatable (followed by an
| Update/commit to the database).
|
| Again, while this all works currently I'm looking for a quicker way to
| migrate the DataGrid changes to the DataTable. I was assuming that some
| client-side coding would be faster than parsing the post data collection
| against the DataGrid data source (DataTable) on the server-side.
|
| Bassel, if I'm missing soming fundamental (wouldn't be the first time)
| please help me understand.
|
| Thanks again!
| Glenn
|
|
| *** Sent via Developersdex http://www.developersdex.com ***
| Don't just participate in USENET...get rewarded for it!
|
|

Nov 17 '05 #5

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

Similar topics

2
4396
by: Steve Mew | last post by:
Has anyone come across a change tracking tool for SQL Server. Specifically the scenario I want is the following : A Production DB needs some modifications to its content. This tool will copy the DB to a dev environment. The Dev environment will be 2 copies of the DB, 1 as a control set and the other the change DB. The developer makes their changes in the Change DB. They test them out and then when they decide the changes are ready to...
6
1634
by: BFX | last post by:
Hi All, I have datagrid with binding on dataset this.grdMachineType.DataMember = "MachineTypes"; this.grdMachineType.DataSource = this.dsMachineTypes; After append new row in datagrid i call this
4
2408
by: Sangeetha. | last post by:
I have a datagrid with just one row. When I edit the contents of the datagrid and click on Save button (somewhere else in the form), the changes are lost. However, if I click TAB from the editable column of the datagrid, the changes are saved. Is there a way to save the changes without clicking TAB button ?
1
1536
by: Muddassir | last post by:
hi everybody I am writing an application for tracking files and directory changes I used FindFirstChangeNotification FindNextChangeNotification FindCloseChangeNotification ReadDirectoryChangesW
1
1590
by: fred tate via .NET 247 | last post by:
I'm working on a project that will track a great deal of data forindividuals and will keep track of users for a very long time (5- 10) years. I'm looking for options as far as tracking anddisplaying changes to the data. Any suggestions for both the UIand the Data Storage aspects of tracking long term changes todata would be helpful. Fred Tate -------------------------------- From: fred tate ----------------------- Posted by a user...
9
2721
by: rn5a | last post by:
A Form has a DataGrid which displays records from a SQL Server 2005 DB table. Users can modify the records using this DataGrid for which I am using EditCommandColumn in the DataGrid. This is the code: <script runat="server"> Dim sqlConn As New SqlConnection(".....") Sub Page_Load(ByVal obj As Object, ByVal ea As EventArgs) If Not (Page.IsPostBack) Then FillDataGrid()
0
1130
by: gtyler | last post by:
When you make changes to a DataGrid a picture of a Pencil appears on the right hand side. As I understand it, the DataSource is not updated until you move off that row and the Pencil disappears. If one of my users were to close the form without remembering to press the “Update Database” button then the changes would be lost. So I wrote a procedure for the On Closing Event that checks for Modified rows, and if there are it prompts the user to...
4
1569
by: tagg3rx | last post by:
Hi all, hoping someone can point me towards a version tracking system for .net development. My projects are starting to get kind of large and my bosses want me to implement some form of version tracking that will allow for the tracking of changes and rolling back of changes. Is there anything out there that does this? Thank You Daniel
2
1322
by: sparks | last post by:
At first they just wanted to keep a record of who logged in and when. Then it was if they made changes. Now its who changed what. BUT since this made no since to them. WHO put it in and who changed it. WTF are they talking about. So every variable will have to be logged at entry and later IF someone changes it it will have to be logged like from and to ...then by who and when ???
0
8652
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
9234
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...
0
9089
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
7831
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...
1
6575
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
5907
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
4667
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3107
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
2402
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.