473,386 Members | 1,598 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

how to see if data changed in DataGrid

Hi,

How can I see if the Data is changed by the user in my DataGrid so I can ask
him to save the changes or not?

Thanks,

Pieter
Nov 21 '05 #1
11 5319
Pieter,

You can check if the underlaying datatable has changes.

Unluckely there is no method datatable.haschanges.

So you should use a workaround something as pseudo

myNewTable as new datatable = datasource.table.getchanges
And than test if that is filled with rows.

I hope that this gives an idea?

Cor
Nov 21 '05 #2
Hm thanks, that seems to work.
But what if I have 2 bound DataTables in my DataGrid, and I wan't only do
the check on the records that are currently in the DataView?

Pieter

"Cor Ligthert" <no**********@planet.nl> wrote in message
news:ev**************@TK2MSFTNGP11.phx.gbl...
Pieter,

You can check if the underlaying datatable has changes.

Unluckely there is no method datatable.haschanges.

So you should use a workaround something as pseudo

myNewTable as new datatable = datasource.table.getchanges
And than test if that is filled with rows.

I hope that this gives an idea?

Cor

Nov 21 '05 #3
Pieter,

The dataview has as well a table property which tells which table it
references

Cor
Hm thanks, that seems to work.
But what if I have 2 bound DataTables in my DataGrid, and I wan't only do
the check on the records that are currently in the DataView?

Nov 21 '05 #4
You could also make a loop foreach through all rows and check their RowState
property - it should be even faster than calling GetChanges.

--
Miha Markic [MVP C#] - RightHand .NET consulting & development
miha at rthand com
www.rthand.com

"DraguVaso" <pi**********@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
Hi,

How can I see if the Data is changed by the user in my DataGrid so I can
ask
him to save the changes or not?

Thanks,

Pieter

Nov 21 '05 #5
Miha,

I like to have the datatable.haschanges

And in a chat was told that they where thinking about it. I think it is
easier than making for every table an own dataset what is as well an
alternative.

Do you understand now?

However I do not think that looping or getchanges would make difference.

:-)

Cor
Nov 21 '05 #6
Thanks,

I gave it a try and it looked at least as fast as the solution of Cor. Maybe
I'm gonna see a difference when I work with bigger DataSets.

Thanks a lot!

Pieter
"Miha Markic [MVP C#]" <miha at rthand com> wrote in message
news:ea****************@tk2msftngp13.phx.gbl...
You could also make a loop foreach through all rows and check their RowState property - it should be even faster than calling GetChanges.

--
Miha Markic [MVP C#] - RightHand .NET consulting & development
miha at rthand com
www.rthand.com

"DraguVaso" <pi**********@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
Hi,

How can I see if the Data is changed by the user in my DataGrid so I can
ask
him to save the changes or not?

Thanks,

Pieter


Nov 21 '05 #7
Hi Cor,

"Cor Ligthert" <no**********@planet.nl> wrote in message
news:uK**************@TK2MSFTNGP10.phx.gbl...
Miha,

I like to have the datatable.haschanges
Yes, me too :-)

And in a chat was told that they where thinking about it. I think it is
easier than making for every table an own dataset what is as well an
alternative.

Do you understand now?
Yes, I did understand before, too :-)
However I do not think that looping or getchanges would make difference.


Oh, it does make a difference.
Imagine a table with 10000 rows and all of them are changed.
If you invoke GetChanges you'll get back a nice copy of entire table while
using a loop, there is no overhead of data returned and you can stop at the
first changed row: :-)

--
Miha Markic [MVP C#] - RightHand .NET consulting & development
miha at rthand com
www.rthand.com
Nov 21 '05 #8
Miha,
Oh, it does make a difference.
Imagine a table with 10000 rows and all of them are changed.
If you invoke GetChanges you'll get back a nice copy of entire table while
using a loop, there is no overhead of data returned and you can stop at the first changed row: :-)


You win this time, I did not think on that, good one.

:-)

Cor
Nov 21 '05 #9
You win this time, I did not think on that, good one.

:-)


That makes Slovenia: Netherland 1:0 :-)
Hey Cor, many people, many solutions. Sometimes you win sometimes you don't.
However, it is not about wining, I really like to see many different
solutions - so I can learn.

--
Miha Markic [MVP C#] - RightHand .NET consulting & development
miha at rthand com
www.rthand.com
Nov 21 '05 #10
Hi,

In addition to the other replies you can use the currencymanger
currentchanged event to be notified of data being changed.
Dim ds As New DataSet

Dim WithEvents cm As CurrencyManager

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

Dim strConn As String

Dim strSQL As String

Dim da As OleDbDataAdapter

strConn = "Provider = Microsoft.Jet.OLEDB.4.0;"

strConn &= "Data Source = Northwind.mdb;"

conn = New OleDbConnection(strConn)

da = New OleDbDataAdapter("Select * From Categories", conn)

da.Fill(ds, "Categories")

DataGrid1.DataSource = ds.Tables("Categories")

cm = CType(Me.BindingContext(DataGrid1.DataSource), CurrencyManager)

End Sub

Private Sub cm_CurrentChanged(ByVal sender As Object, ByVal e As
System.EventArgs) Handles cm.CurrentChanged

MessageBox.Show("Item Changed")

End Sub
Ken
--------------------------------------
"DraguVaso" <pi**********@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
Hi,

How can I see if the Data is changed by the user in my DataGrid so I can ask
him to save the changes or not?

Thanks,

Pieter

Nov 21 '05 #11

"Miha Markic [MVP C#]" <miha at rthand com> wrote in message
news:uz*************@TK2MSFTNGP12.phx.gbl...
That makes Slovenia: Netherland 1:0 :-)


And like usually the Belgians didn't even qualify... ;-)
Nov 21 '05 #12

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

Similar topics

1
by: ali asjad | last post by:
is there any event that is raised when data in datagrid is changed. actually im using a dataset filled through data adapter and is the data source of datagrid Posted Via Usenet.com Premium...
3
by: vinayak | last post by:
Hi I am displaying data in Datagrid in ASP.NET with Edit/Update functionality for each row. On the same page I have 2 Button controls which submits the request to server. These button controls...
0
by: | last post by:
Greets All, Question on data in datagrid /listbox and looping? I’m trying to decide the best way to write this code. 1 would like the user to make several selections from one listbox/combo box...
0
by: | last post by:
Greets All, Question on data in datagrid /listbox and looping? I’m trying to decide the best way to write this code. 1 would like the user to make several selections from one listbox/combo box...
0
by: shil | last post by:
Hi all, I am working on a .net app using Framework 1.1 I have a datagrid which is getting data from a dataset, that is bound to multiple tables. Basically I have a datagrid, a textbox and a...
1
by: Kondapanaidu | last post by:
Hi, I am using .NET 1.1, How to Export the data from Datagrid to PDF file. Lets assume that EMP Table EmpNo Empname 1 AAA
0
by: Ryan Liu | last post by:
Hi, How to capature data changed event in datagrid when the datasource is an ArrayList? I know if the datasource is a datatable, there are events like ColumnChanged, RowChanged, RowDeleted...
1
by: =?Utf-8?B?RG9hbiBOZ3V5ZW4=?= | last post by:
My application is written in VB.NET 2005 to display a table of a SQL 2005 in a datagrid. I want to be notified or capture events when table data changed (inserted, deleted, updated by another user)...
0
by: geeteshss | last post by:
the present problem is that i am unable to display data in datagrid....... but the data is visible in database..below is the code what should i do...earlier i could view it also below this code is...
1
by: Amit | last post by:
Hello , Is there any way i can import data from datagrid to sqlserver. please advise . thanks & Regards
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
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,...

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.