I have a DataSet that contains all my data. From this DataSet, let's call it DS, I have 2 views that are based off of 2 seperate tables. We'll call them DataView History and DataView Info. I have a grid on my winForm that is dataBound to the Info view along with 2 combo boxes and 1 datetime picker. Everything works fine with these controls so that the filtering is done automatically by the grid. The other DataView, is bound to textboxes on another tab in my winForm. When I type information into these textboxes, change focus or leave focus, and try to click a button to that calls a save function that calls BindingContext[].EndCurrentEdit() for a tables in the DS. Then immediately after I check the DS to see if it has any changes by calling DS.HasChanges()... this function always returns false. If I debug my program, and pause it right at the HasChanges() step, i can check the following: DS.Tables["Info"].Rows[0]["address"] and I get the value that I entered into the textbox.
Why does the DS think that there is no changes to itself when I can clearly see that there is something there that wasn't before?
If I didn't give enough info, let me know... I'm still alittle new to this stuff
8 2093
I have a DataSet that contains all my data. From this DataSet, let's call it DS, I have 2 views that are based off of 2 seperate tables. We'll call them DataView History and DataView Info. I have a grid on my winForm that is dataBound to the Info view along with 2 combo boxes and 1 datetime picker. Everything works fine with these controls so that the filtering is done automatically by the grid. The other DataView, is bound to textboxes on another tab in my winForm. When I type information into these textboxes, change focus or leave focus, and try to click a button to that calls a save function that calls BindingContext[].EndCurrentEdit() for a tables in the DS. Then immediately after I check the DS to see if it has any changes by calling DS.HasChanges()... this function always returns false. If I debug my program, and pause it right at the HasChanges() step, i can check the following: DS.Tables["Info"].Rows[0]["address"] and I get the value that I entered into the textbox.
Why does the DS think that there is no changes to itself when I can clearly see that there is something there that wasn't before?
If I didn't give enough info, let me know... I'm still alittle new to this stuff
Please look at this example.
Nathan
I looked at that example and called DS.GetChanges() and DS.GetChanges(DataRowState.Modified) and both returned null. I've also tried the following:
foreach(DataRow r in DS.Tables["Info"].Rows)
{
if(r["address"].RowState == DataRowState.Modified)
{
//debug here, even though it never gets here
}
}
so there seems to be no rows (atleast to the DS) that have had any changes...
thanks for the fast response!
I looked at that example and called DS.GetChanges() and DS.GetChanges(DataRowState.Modified) and both returned null. I've also tried the following:
foreach(DataRow r in DS.Tables["Info"].Rows)
{
if(r["address"].RowState == DataRowState.Modified)
{
//debug here, even though it never gets here
}
}
so there seems to be no rows (atleast to the DS) that have had any changes...
thanks for the fast response!
I also found this example. Let us know if trying the code in this example works for you.
Nathan
yeah, i've run along this code out there and I'm nearly doing the same thing... I'm binding my textboxes with the following:
textBoxAddress1.DataBindings.Add("Text", _dependentsContactView, "contactinfo_address1");
and I've also tried:
textBoxAddress1.DataBindings.Add("Text", _dependentsContactView, "contactinfo_address1").ControlUpdateMode = ControlUpdateMode.OnPropertyChanged;
and also:
textBoxAddress1.DataBindings.Add("Text", _dependentsContactView, "contactinfo_address1").DataSourceUpdateMode = DataSourceUpdateMode.OnPropertyChanged;
still no luck...I've tried now to debug the program when the TextChanged event is raised of my textbox. When I type something new in the text box (1 letter at a time) and debug the program and look at the DS.Tables["Info"].Rows[1]["address"] which has the original value, the rowstate for this row which is Unchanged, and the Text value of my textbox which as the new letter i typed. I just through in Row[1] because it just happens to be the row, for ease of debug use. But here's what I don't understand... when i click off of the textbox and back onto it again and type 1 more character, i enter into debug mode again. But this time, the DS contains the changes that the textbox had when it lost focus, ok, but the RowState is still Unchanged.... shouldn't the RowState have been updated since the data inside the row had been changed?
yeah, i've run along this code out there and I'm nearly doing the same thing... I'm binding my textboxes with the following:
textBoxAddress1.DataBindings.Add("Text", _dependentsContactView, "contactinfo_address1");
and I've also tried:
textBoxAddress1.DataBindings.Add("Text", _dependentsContactView, "contactinfo_address1").ControlUpdateMode = ControlUpdateMode.OnPropertyChanged;
still no luck...I've tried now to debug the program when the TextChanged event is raised of my textbox. When I type something new in the text box (1 letter at a time) and debug the program and look at the DS.Tables["Info"].Rows[1]["address"] which has the original value, the rowstate for this row which is Unchanged, and the Text value of my textbox which as the new letter i typed. I just through in Row[1] because it just happens to be the row, for ease of debug use. But here's what I don't understand... when i click off of the textbox and back onto it again and type 1 more character, i enter into debug mode again. But this time, the DS contains the changes that the textbox had when it lost focus, ok, but the RowState is still Unchanged.... shouldn't the RowState have been updated since the data inside the row had been changed?
Are you calling the AcceptChanges method?
no, the AcceptChanges() will be called after the DS has been sent to the database and comes back
Well, I found a method that works, but I'm not sure how clean it is. On my databinding area, i set my text boxes to all be bound like the following:
textBoxAddress1.DataBindings.Add("Text", _dependentsContactView, "contactinfo_address1").DataSourceUpdateMode = DataSourceUpdateMode.OnPropertyChanged;
I added the ".DataSourceUpdateMode = DataSourceUpdateMode.OnPropertyChanged;" so that the user wouldn't have to click out of the textbox before clicking save.
But what I did in my save method is that I had to run through all all the rows in the view that I had created:
for (int i = 0; i < _dependentsContactView.Count; i++)
_dependentsContactView[i].EndEdit();
This modified the RowState of the correct rows to me "Modified" instead of "Unchanged". After this, I'm still running through all of my DS tables and calling EndCurrentEdit() on them. After that I'm checking to see if DS.HasChanges() is true (thank goodness it finally is, YEAH!!!) then I'm saving.
I was originally thinking that if I'm calling EndCurrentEdit() on the DS then that should work, but I have to EndEdit() first on the view based off of that table!
Thanks for all the help, I really appreciate it
Well, I found a method that works, but I'm not sure how clean it is. On my databinding area, i set my text boxes to all be bound like the following:
textBoxAddress1.DataBindings.Add("Text", _dependentsContactView, "contactinfo_address1").DataSourceUpdateMode = DataSourceUpdateMode.OnPropertyChanged;
I added the ".DataSourceUpdateMode = DataSourceUpdateMode.OnPropertyChanged;" so that the user wouldn't have to click out of the textbox before clicking save.
But what I did in my save method is that I had to run through all all the rows in the view that I had created:
for (int i = 0; i < _dependentsContactView.Count; i++)
_dependentsContactView[i].EndEdit();
This modified the RowState of the correct rows to me "Modified" instead of "Unchanged". After this, I'm still running through all of my DS tables and calling EndCurrentEdit() on them. After that I'm checking to see if DS.HasChanges() is true (thank goodness it finally is, YEAH!!!) then I'm saving.
I was originally thinking that if I'm calling EndCurrentEdit() on the DS then that should work, but I have to EndEdit() first on the view based off of that table!
Thanks for all the help, I really appreciate it
Great. I am glad you were able to find a solution. Thank you for sharing.
Nathan
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Edward |
last post by:
I have the following function to determine if a form is loaded:
Public Function modIsloaded(ByVal vstrFormName As String) As Boolean
' Error handling removed for concision
' Determine if...
|
by: Jean Stax |
last post by:
Hi !
I created a sample library project. In my second project I reference
this library
and make the following call, which returns "undefined value":
Type myType =...
|
by: Michiel |
last post by:
Hello,
I'm trying to retrieve my cpu load as follows :
PerformanceCounter* cpuCounter = new PerformanceCounter("Processor", "%
Processor Time", "_Total");
float value =...
|
by: Stephan |
last post by:
Hi,
I'm working on a page with multiple Datalist-controls on it. The
problem I'm facing is that when I try to update a record, the
ItemIndex returns a value which is one lower than the Item I...
|
by: chellappa |
last post by:
hi All,
function automatically returns the value,am not used "return"
i am using Linux -gcc complier
please tell me.... what is problem...
source
=====
#include <stdio.h>
main()
{
|
by: nikolacace |
last post by:
Hi,
I have a stored procedure (the code is below) that I use to retrieve
one value from my database. I tested the code in Query Analyzer, and it
works (I get the value I was looking for). However,...
|
by: ApexData |
last post by:
Hello
I completed an application that worked great until I went to STARTUP
and shut off all of the checkboxes. My code uses
"Application.CurrentObjectName" to get the current Form name.
All my...
|
by: `Zidane Tribal |
last post by:
it would appear that using the command 'crc("data")' from the String::CRC
returns incorrect results (although, they are at least consistently
incorrect).
for example, this script.....
...
|
by: mcfly1204 |
last post by:
The following query only returns one value when several are expected.
SELECT @contactid = Con.CONTACTID, @accountid = Con.ACCOUNTID, @lastname = LASTNAME, @firstname = FIRSTNAME, @email = EMAIL,...
|
by: Rina0 |
last post by:
Cybersecurity engineering is a specialized field that focuses on the design, development, and implementation of systems, processes, and technologies that protect against cyber threats and...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM)
The start time is equivalent to 19:00 (7PM) in Central...
|
by: erikbower65 |
last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA:
1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
|
by: kcodez |
last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
|
by: Taofi |
last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same
This are my field names
ID, Budgeted, Actual, Status and Differences
...
|
by: DJRhino1175 |
last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this -
If...
|
by: DJRhino |
last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer)
If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _
310030356 Or 310030359 Or 310030362 Or...
|
by: Mushico |
last post by:
How to calculate date of retirement from date of birth
|
by: DJRhino |
last post by:
Was curious if anyone else was having this same issue or not....
I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
| |