473,399 Members | 4,192 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,399 software developers and data experts.

RowChanged event

If I add a handler to the row changed event of a datatable, it fires
when a row has been added, but when in the event, it hasn't actually
added the row yet... Is there a way around this? How can I make sure
that the row has been added to the dataset during this event? Or is
there another one I have to hook into?

Thanks,
Aaron
--
---
Aaron Smith
Remove -1- to E-Mail me. Spam Sucks.
Nov 21 '05 #1
8 1399
This only fires once the row is added, otherwise it would not have the value
in it )

Private WithEvents myTable As New DataTable

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

Dim r As DataRow

Dim c As New DataColumn

r = myTable.NewRow()

r(0) = "Row Added"

myTable.Rows.Add(r)

End Sub

Private Sub myTable_RowChanged(ByVal sender As Object, ByVal e As
System.Data.DataRowChangeEventArgs) Handles myTable.RowChanged

Debug.WriteLine(e.Row()(0).ToString)

End Sub

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

myTable.Columns.Add("Hello")

End Sub

"Aaron Smith" <th**********@smithcentral.net> wrote in message
news:Rz******************@newssvr17.news.prodigy.c om...
If I add a handler to the row changed event of a datatable, it fires
when a row has been added, but when in the event, it hasn't actually
added the row yet... Is there a way around this? How can I make sure
that the row has been added to the dataset during this event? Or is
there another one I have to hook into?

Thanks,
Aaron
--
---
Aaron Smith
Remove -1- to E-Mail me. Spam Sucks.

Nov 21 '05 #2
That is only partially correct. e.Row has the data, but while in the
event, the dataset does not have the row... So, inside that event,
calling any kind of update routine that uses the dataset, such as
updating the data source, it will not have any new rows in it.

In your RowChanged event handler, do a writeline on the number of rows
in the datatable... it won't include the new row..

OHM ( Terry Burns ) wrote:
This only fires once the row is added, otherwise it would not have the value
in it )

Private WithEvents myTable As New DataTable

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

Dim r As DataRow

Dim c As New DataColumn

r = myTable.NewRow()

r(0) = "Row Added"

myTable.Rows.Add(r)

End Sub

Private Sub myTable_RowChanged(ByVal sender As Object, ByVal e As
System.Data.DataRowChangeEventArgs) Handles myTable.RowChanged

Debug.WriteLine(e.Row()(0).ToString)

End Sub

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

myTable.Columns.Add("Hello")

End Sub

"Aaron Smith" <th**********@smithcentral.net> wrote in message
news:Rz******************@newssvr17.news.prodigy.c om...
If I add a handler to the row changed event of a datatable, it fires
when a row has been added, but when in the event, it hasn't actually
added the row yet... Is there a way around this? How can I make sure
that the row has been added to the dataset during this event? Or is
there another one I have to hook into?

Thanks,
Aaron
--
---
Aaron Smith
Remove -1- to E-Mail me. Spam Sucks.


--
---
Aaron Smith
Remove -1- to E-Mail me. Spam Sucks.
Nov 21 '05 #3
Yes, but it needs to have been commited to acheive this, check this modified
code out

Dim r As DataRow

Dim c As New DataColumn

r = myTable.NewRow()

r(0) = "Screw You"

myTable.Rows.Add(r)

myTable.AcceptChanges()

End Sub

Private Shared Sub myTable_RowChanged(ByVal sender As Object, ByVal e As
System.Data.DataRowChangeEventArgs) Handles myTable.RowChanged

Dim m As DataTable = CType(sender, DataTable)

If e.Action = DataRowAction.Commit Then

Debug.WriteLine(m.Rows.Count.ToString)

End If

End Sub


"Aaron Smith" <th**********@smithcentral.net> wrote in message
news:L3*******************@newssvr17.news.prodigy. com...
That is only partially correct. e.Row has the data, but while in the
event, the dataset does not have the row... So, inside that event,
calling any kind of update routine that uses the dataset, such as
updating the data source, it will not have any new rows in it.

In your RowChanged event handler, do a writeline on the number of rows
in the datatable... it won't include the new row..

OHM ( Terry Burns ) wrote:
This only fires once the row is added, otherwise it would not have the value in it )

Private WithEvents myTable As New DataTable

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

Dim r As DataRow

Dim c As New DataColumn

r = myTable.NewRow()

r(0) = "Row Added"

myTable.Rows.Add(r)

End Sub

Private Sub myTable_RowChanged(ByVal sender As Object, ByVal e As
System.Data.DataRowChangeEventArgs) Handles myTable.RowChanged

Debug.WriteLine(e.Row()(0).ToString)

End Sub

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

myTable.Columns.Add("Hello")

End Sub

"Aaron Smith" <th**********@smithcentral.net> wrote in message
news:Rz******************@newssvr17.news.prodigy.c om...
If I add a handler to the row changed event of a datatable, it fires
when a row has been added, but when in the event, it hasn't actually
added the row yet... Is there a way around this? How can I make sure
that the row has been added to the dataset during this event? Or is
there another one I have to hook into?

Thanks,
Aaron
--
---
Aaron Smith
Remove -1- to E-Mail me. Spam Sucks.


--
---
Aaron Smith
Remove -1- to E-Mail me. Spam Sucks.

Nov 21 '05 #4
PS, ignore the word 'Screw You' in the code, I often write stuff like that
when Im testing, it keeps me happy
"Aaron Smith" <th**********@smithcentral.net> wrote in message
news:L3*******************@newssvr17.news.prodigy. com...
That is only partially correct. e.Row has the data, but while in the
event, the dataset does not have the row... So, inside that event,
calling any kind of update routine that uses the dataset, such as
updating the data source, it will not have any new rows in it.

In your RowChanged event handler, do a writeline on the number of rows
in the datatable... it won't include the new row..

OHM ( Terry Burns ) wrote:
This only fires once the row is added, otherwise it would not have the value in it )

Private WithEvents myTable As New DataTable

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

Dim r As DataRow

Dim c As New DataColumn

r = myTable.NewRow()

r(0) = "Row Added"

myTable.Rows.Add(r)

End Sub

Private Sub myTable_RowChanged(ByVal sender As Object, ByVal e As
System.Data.DataRowChangeEventArgs) Handles myTable.RowChanged

Debug.WriteLine(e.Row()(0).ToString)

End Sub

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

myTable.Columns.Add("Hello")

End Sub

"Aaron Smith" <th**********@smithcentral.net> wrote in message
news:Rz******************@newssvr17.news.prodigy.c om...
If I add a handler to the row changed event of a datatable, it fires
when a row has been added, but when in the event, it hasn't actually
added the row yet... Is there a way around this? How can I make sure
that the row has been added to the dataset during this event? Or is
there another one I have to hook into?

Thanks,
Aaron
--
---
Aaron Smith
Remove -1- to E-Mail me. Spam Sucks.


--
---
Aaron Smith
Remove -1- to E-Mail me. Spam Sucks.

Nov 21 '05 #5
Ok, but does that only get called when an Update is being called on the
dataadapter? If it is, then that kind of defeats what I was trying to do
there... What I was ultimately trying to have happen was have the
datasource be updated with the changes everytime a row was changed... I
think I have it figured out with the position event of the
bindingcontext... But I would like to figure out a way to do it with
rowchanged.... I guess it's 6 of 1, half dozen of another. If I can get
it work one way, I should quit complaining. lol

OHM ( Terry Burns ) wrote:
Yes, but it needs to have been commited to acheive this, check this modified
code out

Dim r As DataRow

Dim c As New DataColumn

r = myTable.NewRow()

r(0) = "Screw You"

myTable.Rows.Add(r)

myTable.AcceptChanges()

End Sub

Private Shared Sub myTable_RowChanged(ByVal sender As Object, ByVal e As
System.Data.DataRowChangeEventArgs) Handles myTable.RowChanged

Dim m As DataTable = CType(sender, DataTable)

If e.Action = DataRowAction.Commit Then

Debug.WriteLine(m.Rows.Count.ToString)

End If

End Sub


"Aaron Smith" <th**********@smithcentral.net> wrote in message
news:L3*******************@newssvr17.news.prodigy. com...
That is only partially correct. e.Row has the data, but while in the
event, the dataset does not have the row... So, inside that event,
calling any kind of update routine that uses the dataset, such as
updating the data source, it will not have any new rows in it.

In your RowChanged event handler, do a writeline on the number of rows
in the datatable... it won't include the new row..

OHM ( Terry Burns ) wrote:
This only fires once the row is added, otherwise it would not have the
value
in it )

Private WithEvents myTable As New DataTable

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

Dim r As DataRow

Dim c As New DataColumn

r = myTable.NewRow()

r(0) = "Row Added"

myTable.Rows.Add(r)

End Sub

Private Sub myTable_RowChanged(ByVal sender As Object, ByVal e As
System.Data.DataRowChangeEventArgs) Handles myTable.RowChanged

Debug.WriteLine(e.Row()(0).ToString)

End Sub

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

myTable.Columns.Add("Hello")

End Sub

"Aaron Smith" <th**********@smithcentral.net> wrote in message
news:Rz******************@newssvr17.news.prodig y.com...
If I add a handler to the row changed event of a datatable, it fires
when a row has been added, but when in the event, it hasn't actually
added the row yet... Is there a way around this? How can I make sure
that the row has been added to the dataset during this event? Or is
there another one I have to hook into?

Thanks,
Aaron
--
---
Aaron Smith
Remove -1- to E-Mail me. Spam Sucks.


--
---
Aaron Smith
Remove -1- to E-Mail me. Spam Sucks.


--
---
Aaron Smith
Remove -1- to E-Mail me. Spam Sucks.
Nov 21 '05 #6
Thats ok. I laughed when I saw it because I did something similar in one
of the data tables I was working in. The boss happened to run that
program to see if I made any changes to the screen.... he came to my
cube and said, "Having a bad day?" lol

OHM ( Terry Burns ) wrote:
PS, ignore the word 'Screw You' in the code, I often write stuff like that
when Im testing, it keeps me happy

--
---
Aaron Smith
Remove -1- to E-Mail me. Spam Sucks.
Nov 21 '05 #7
Yes your right, I dont think you will be able to do what your after with the
RowChange event, the Add action allows last minute validation, it seems to
have been designed this way.

As you say, the binding contect route is probably the way 2 go

--
OHM ( Terry Burns ) * Use the following to email me *

Dim ch() As Char = "ufssz/cvsotAhsfbuTpmvujpotXjui/OFU".ToCharArray()
For i As Int32 = 0 To ch.Length - 1
ch(i) = Convert.ToChar(Convert.ToInt16(ch(i)) - 1)
Next
Process.Start("mailto:" & New String(ch))
--
"Aaron Smith" <th**********@smithcentral.net> wrote in message
news:xW******************@newssvr17.news.prodigy.c om...
Ok, but does that only get called when an Update is being called on the
dataadapter? If it is, then that kind of defeats what I was trying to do
there... What I was ultimately trying to have happen was have the
datasource be updated with the changes everytime a row was changed... I
think I have it figured out with the position event of the
bindingcontext... But I would like to figure out a way to do it with
rowchanged.... I guess it's 6 of 1, half dozen of another. If I can get
it work one way, I should quit complaining. lol

OHM ( Terry Burns ) wrote:
Yes, but it needs to have been commited to acheive this, check this modified code out

Dim r As DataRow

Dim c As New DataColumn

r = myTable.NewRow()

r(0) = "Screw You"

myTable.Rows.Add(r)

myTable.AcceptChanges()

End Sub

Private Shared Sub myTable_RowChanged(ByVal sender As Object, ByVal e As
System.Data.DataRowChangeEventArgs) Handles myTable.RowChanged

Dim m As DataTable = CType(sender, DataTable)

If e.Action = DataRowAction.Commit Then

Debug.WriteLine(m.Rows.Count.ToString)

End If

End Sub


"Aaron Smith" <th**********@smithcentral.net> wrote in message
news:L3*******************@newssvr17.news.prodigy. com...
That is only partially correct. e.Row has the data, but while in the
event, the dataset does not have the row... So, inside that event,
calling any kind of update routine that uses the dataset, such as
updating the data source, it will not have any new rows in it.

In your RowChanged event handler, do a writeline on the number of rows
in the datatable... it won't include the new row..

OHM ( Terry Burns ) wrote:

This only fires once the row is added, otherwise it would not have the


value
in it )

Private WithEvents myTable As New DataTable

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

Dim r As DataRow

Dim c As New DataColumn

r = myTable.NewRow()

r(0) = "Row Added"

myTable.Rows.Add(r)

End Sub

Private Sub myTable_RowChanged(ByVal sender As Object, ByVal e As
System.Data.DataRowChangeEventArgs) Handles myTable.RowChanged

Debug.WriteLine(e.Row()(0).ToString)

End Sub

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

myTable.Columns.Add("Hello")

End Sub

"Aaron Smith" <th**********@smithcentral.net> wrote in message
news:Rz******************@newssvr17.news.prodig y.com...
>If I add a handler to the row changed event of a datatable, it fires
>when a row has been added, but when in the event, it hasn't actually
>added the row yet... Is there a way around this? How can I make sure
>that the row has been added to the dataset during this event? Or is
>there another one I have to hook into?
>
>Thanks,
>Aaron
>--
>---
>Aaron Smith
>Remove -1- to E-Mail me. Spam Sucks.


--
---
Aaron Smith
Remove -1- to E-Mail me. Spam Sucks.


--
---
Aaron Smith
Remove -1- to E-Mail me. Spam Sucks.

Nov 21 '05 #8
Ok, thanks Terry.. I guess I just needed verification.. I'm just
starting out at this and trying to get used to everything... The Data
Form Wizard sure does a lot of strange things.... I ended up commenting
out the UpdataDataSet routine in there and just putting in
dataadapter.Update ... Seems to work a little cleaner for some reason...

OHM ( Terry Burns ) wrote:
Yes your right, I dont think you will be able to do what your after with the
RowChange event, the Add action allows last minute validation, it seems to
have been designed this way.

As you say, the binding contect route is probably the way 2 go

--
OHM ( Terry Burns ) * Use the following to email me *

Dim ch() As Char = "ufssz/cvsotAhsfbuTpmvujpotXjui/OFU".ToCharArray()
For i As Int32 = 0 To ch.Length - 1
ch(i) = Convert.ToChar(Convert.ToInt16(ch(i)) - 1)
Next
Process.Start("mailto:" & New String(ch))
--
"Aaron Smith" <th**********@smithcentral.net> wrote in message
news:xW******************@newssvr17.news.prodigy.c om...
Ok, but does that only get called when an Update is being called on the
dataadapter? If it is, then that kind of defeats what I was trying to do
there... What I was ultimately trying to have happen was have the
datasource be updated with the changes everytime a row was changed... I
think I have it figured out with the position event of the
bindingcontext... But I would like to figure out a way to do it with
rowchanged.... I guess it's 6 of 1, half dozen of another. If I can get
it work one way, I should quit complaining. lol

OHM ( Terry Burns ) wrote:
Yes, but it needs to have been commited to acheive this, check this
modified
code out

Dim r As DataRow

Dim c As New DataColumn

r = myTable.NewRow()

r(0) = "Screw You"

myTable.Rows.Add(r)

myTable.AcceptChanges()

End Sub

Private Shared Sub myTable_RowChanged(ByVal sender As Object, ByVal e As
System.Data.DataRowChangeEventArgs) Handles myTable.RowChanged

Dim m As DataTable = CType(sender, DataTable)

If e.Action = DataRowAction.Commit Then

Debug.WriteLine(m.Rows.Count.ToString)

End If

End Sub


"Aaron Smith" <th**********@smithcentral.net> wrote in message
news:L3*******************@newssvr17.news.prodi gy.com...
That is only partially correct. e.Row has the data, but while in the
event, the dataset does not have the row... So, inside that event,
calling any kind of update routine that uses the dataset, such as
updating the data source, it will not have any new rows in it.

In your RowChanged event handler, do a writeline on the number of rows
in the datatable... it won't include the new row..

OHM ( Terry Burns ) wrote:
>This only fires once the row is added, otherwise it would not have the

value
>in it )
>
>Private WithEvents myTable As New DataTable
>
>Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
>System.EventArgs) Handles Button1.Click
>
>Dim r As DataRow
>
>Dim c As New DataColumn
>
>r = myTable.NewRow()
>
>r(0) = "Row Added"
>
>myTable.Rows.Add(r)
>
>
>
>End Sub
>
>Private Sub myTable_RowChanged(ByVal sender As Object, ByVal e As
>System.Data.DataRowChangeEventArgs) Handles myTable.RowChanged
>
>Debug.WriteLine(e.Row()(0).ToString)
>
>End Sub
>
>Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
>System.EventArgs) Handles MyBase.Load
>
>myTable.Columns.Add("Hello")
>
>End Sub
>
>"Aaron Smith" <th**********@smithcentral.net> wrote in message
>news:Rz******************@newssvr17.news.prod igy.com...
>
>
>
>>If I add a handler to the row changed event of a datatable, it fires
>>when a row has been added, but when in the event, it hasn't actually
>>added the row yet... Is there a way around this? How can I make sure
>>that the row has been added to the dataset during this event? Or is
>>there another one I have to hook into?
>>
>>Thanks,
>>Aaron
>>--
>>---
>>Aaron Smith
>>Remove -1- to E-Mail me. Spam Sucks.
>
>
>
--
---
Aaron Smith
Remove -1- to E-Mail me. Spam Sucks.


--
---
Aaron Smith
Remove -1- to E-Mail me. Spam Sucks.


--
---
Aaron Smith
Remove -1- to E-Mail me. Spam Sucks.
Nov 21 '05 #9

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

Similar topics

0
by: ZAky | last post by:
In Rowchanged event handler the datasource table do not contain the new row added. The DataRowChangeEventArgs contain information about the new row. So, if i try to use...
7
by: Beffmans | last post by:
Hi I wonder if there was something like a an event for an asp.net datagrid which fire swhen you change (part of) that row? I am trying to mark rows which have been changed to update later . ...
2
by: Peter van der Veen | last post by:
Hi Why is there not a rowchanged event is listview??? I display some extra information when a user changed rows. i tried to use the selectedindexchaned event, but get errors when trying to...
2
by: Zorpiedoman | last post by:
I have a control, it is bound to a field in a datatable. If I change the value in the textbox, and move off the textbox, the RowChanged event is NOT called. Is there some way to change this...
41
by: JohnR | last post by:
In it's simplest form, assume that I have created a usercontrol, WSToolBarButton that contains a button. I would like to eventually create copies of WSToolBarButton dynamically at run time based...
9
by: astro | last post by:
I've tried the following without success....... AddHandler DS1.Tables("dial").RowChanged, AddressOf after_row_insert AddHandler CType(Me.dgDials.DataSource, DataTable).RowChanged, AddressOf...
1
by: astro | last post by:
I am trapping the rowchanged event on a table. I have the following code: If e.Action = DataRowAction.Add Then ds.Merge(CType(sender, DataTable).Select("", "",...
9
by: jeff | last post by:
New VB user...developer... Situation...simplified... - I want to wrap a pre and post event around a system generated where the pre-event will always execute before the system event and the...
0
by: shanmuk | last post by:
when ever a row focus changes in the datagrid,columns in the previous row are populated with some text .i have written a datagridview_rowfocuschanged event but i am unable to fire the event for the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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?
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
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
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,...
0
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
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
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,...

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.