djdidge
asked on
annoying! (DataRowState.Modified)
Hi All,
I have various controls on a tab page. After i run the fill from the dataadapter i get (DataRowState.Modified = true) fair enough i thought, perhaps somthing minor is getting changed during the databind. So i update the dataset and get (DataRowState.Modified = false). Thats good you would imagine the dataset is sitting pretty ready to detect any real changes made by the user.
However it seems that when i change tabs (via tab validate event) even without making a manual change to the dataset (via bound controls), the (DataRowState.Modified) ends up being true and hence the user is prompted to save changes.
Something anomolous is changing the rowstate!
Ideas?
Regards
DiDGE
I have various controls on a tab page. After i run the fill from the dataadapter i get (DataRowState.Modified = true) fair enough i thought, perhaps somthing minor is getting changed during the databind. So i update the dataset and get (DataRowState.Modified = false). Thats good you would imagine the dataset is sitting pretty ready to detect any real changes made by the user.
However it seems that when i change tabs (via tab validate event) even without making a manual change to the dataset (via bound controls), the (DataRowState.Modified) ends up being true and hence the user is prompted to save changes.
Something anomolous is changing the rowstate!
Ideas?
Regards
DiDGE
When you change tab pages are you rebinding your dataset? That would cause the Modified bit to get set.
ASKER
im unbinding and rebinding a lot unfortunately as i couldnt seem to get a consistent binding context working.
However, as a test i added a command button that updated the dataset and msgboxed DataRowState.Modified... So as a test i click the update button just before i change the tab... this should save any and all changes and it return modified as false (which it does). And yet when i click the tab straight after modified = true and i get it asking to update again :o/
However, as a test i added a command button that updated the dataset and msgboxed DataRowState.Modified... So as a test i click the update button just before i change the tab... this should save any and all changes and it return modified as false (which it does). And yet when i click the tab straight after modified = true and i get it asking to update again :o/
Gotcha. But, when the tab page is changed, do you rebind the dataset? In other words, do you rebind in the tabpage changed event handler?
ASKER
Having added breakpoints to check that the unbind/rebind isnt running without me knowing i can confirm that it happens elsewhere, and so doesnt seem to be what is causing this :o/
One thing you could try is after you bind the dataset, call the AcceptChanges method which will clear that flag. See if that works.
ASKER
ok...
I did this MsgBox(dsProd.HasChanges(D ataRowStat e.Modified )) just after the binds and it returned False .... this means that binding isnt the issue
I did this MsgBox(dsProd.HasChanges(D ataRowStat e.Modified )) it returned false
Me.tabAll.SelectedTab = tabMain
MsgBox(dsProd.HasChanges(D ataRowStat e.Modified )) it returned true
so it looks like the 'selectedTab = ' bit changes the rowstate
on the first 'selectedTab = ' i can use the AcceptChanges bit as no data has been changed (this is the case as we have just come from a 'search' tab to the edit tab (tabmain)), this saves me doing an update atleast. But as for a true validation of changes when i change tab im at a loss.
I have to be honest tab pages are almost more hasle than they are worth!
I did this MsgBox(dsProd.HasChanges(D
I did this MsgBox(dsProd.HasChanges(D
Me.tabAll.SelectedTab = tabMain
MsgBox(dsProd.HasChanges(D
so it looks like the 'selectedTab = ' bit changes the rowstate
on the first 'selectedTab = ' i can use the AcceptChanges bit as no data has been changed (this is the case as we have just come from a 'search' tab to the edit tab (tabmain)), this saves me doing an update atleast. But as for a true validation of changes when i change tab im at a loss.
I have to be honest tab pages are almost more hasle than they are worth!
Wait a sec. I asked the wrong question. DUH! :-| When you change tab pages are you re-filling the dataset? Can you post some code so we can see what is going on?
ASKER
there are about 7 tabs... the first is a search page. Selections made from there take the user to tabmain. The fill happens here.
I would be happy to post code but tbh i'm really not sure which part might be relevant as the project is fairly big.
If i could store the rowstate in a seperate boolean i could evaluate that instead. The only problem with that would be finding a suitable event to use to update the boolean. Ideally it would be on an event attached to the click of the tab header, but i cant seem to find one that will fire at a suitable time (before the rowstate is changed by the annoying tabpage!)
I would be happy to post code but tbh i'm really not sure which part might be relevant as the project is fairly big.
If i could store the rowstate in a seperate boolean i could evaluate that instead. The only problem with that would be finding a suitable event to use to update the boolean. Ideally it would be on an event attached to the click of the tab header, but i cant seem to find one that will fire at a suitable time (before the rowstate is changed by the annoying tabpage!)
ASKER
perhaps i could put a line object (or .net equiv) along the bottom of the tab heads and use the mouse over event.... a bit dirty, but novell i guess.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Incidentally, there is no .Net equivalent of the VB6 line object. You would have to draw the line yourself using GDI+ and maintain it's state etc...not pretty.
If you wanted to try that route, you could put a label control on the tab header and use it instead of the Text property for the tab page. Not sure if that would work good or not, but it may be worth a try if what I suggested above doesn't cut the mustard.
If you wanted to try that route, you could put a label control on the tab header and use it instead of the Text property for the tab page. Not sure if that would work good or not, but it may be worth a try if what I suggested above doesn't cut the mustard.
ASKER
i can see how that might work with some designs, however my prog works a little differently. But its almost what i described above.
However i think i have made a breakthrough! i tried validating the rowstate right at the beginning of the tabMain_Validating sub... it was False! hence i can use that true condition to decide weather to update or not.
unfortunately my time has run out for today. I must leave for home now. But i will check this first thing in the morning and then hopefully close the question.
Thanks for your help today.
Speak to you tomorrow.
Regards
DiDGE
However i think i have made a breakthrough! i tried validating the rowstate right at the beginning of the tabMain_Validating sub... it was False! hence i can use that true condition to decide weather to update or not.
unfortunately my time has run out for today. I must leave for home now. But i will check this first thing in the morning and then hopefully close the question.
Thanks for your help today.
Speak to you tomorrow.
Regards
DiDGE
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
it seems to be not related to the tabpage click....
with the rowstate set as FALSE (after fill)...
without making any manual changes to the bound controls i run this code...
fMain.BindingContext(dsPro d, "ProdRec").EndCurrentEdit( )
MsgBox(dsProd.HasChanges(D ataRowStat e.Modified ))
and it returns TRUE! what is going on here! It should be FALSE because ive not made any changes! Am i misunderstanding how thsi whole thing works?!
Regards
DiDGE
with the rowstate set as FALSE (after fill)...
without making any manual changes to the bound controls i run this code...
fMain.BindingContext(dsPro
MsgBox(dsProd.HasChanges(D
and it returns TRUE! what is going on here! It should be FALSE because ive not made any changes! Am i misunderstanding how thsi whole thing works?!
Regards
DiDGE
ASKER
do i need to use a BindingManagerBase ?
Hi ,
I have a similar problem but will post a new question to raise the profile of the topic.
DSE
I have a similar problem but will post a new question to raise the profile of the topic.
DSE
ASKER
Having opened a similar thread on http://www.visualbasicforum.com/showthread.php?t=182796 it seems that calling EndCurrentEdit will always set the rowstate.modifed = true
for my purposes a true value of rowstate.modifed can be gained by editing a text box and then changing focus to another bound control.
Ill leave the question open for a few days to facilitate further discussion then i will close.
Regards
DiDGE
for my purposes a true value of rowstate.modifed can be gained by editing a text box and then changing focus to another bound control.
Ill leave the question open for a few days to facilitate further discussion then i will close.
Regards
DiDGE
ASKER
...it looks like i dont have to change focus afterall
ASKER
my thread Date: 08/11/2004 01:49PM BST was eventually the resolution i was looking for but to give credit for helping me work towards the solution im awarding the points to both contributors.