?
Solved

Strange Behavior : TextBox.Text got cleared after calling Me.BindingContext(DataSet1.Tables("DETAIL")).AddNew()

Posted on 2005-03-12
7
Medium Priority
?
362 Views
Last Modified: 2010-04-23
i am using VB.Net 2003

i found a strange behavior:
after calling Me.BindingContext(DataSet1.Tables("DETAIL")).AddNew(),
TWO of my TextBox.Text values got cleared automatically.
this weird behavior occured when DataSet1.Tables("DETAIL") already has a RECORD or more,
thus if the table is EMPTY, this behavior did not occured, all my TextBoxes.Text values did not get cleared

this is my code:
Note: all TextBoxes except txtID are in GroupBox1

Dim BMB As BindingManagerBase = Me.BindingContext(DataSet1.Tables("DETAIL"))

BMB.EndCurrentEdit()
BMB.AddNew() '--> after this call, two of my TextBox.Text values got cleared
BMB.Current("SRExportID") = Trim(txtID.Text)
BMB.Current("Article") = Trim(txtArticle.Text) '--> this TextBox.Text got cleared
BMB.Current("Material1") = Trim(txtMaterial1.Text)
BMB.Current("Material2") = Trim(txtMaterial2.Text)
BMB.Current("Material3") = Trim(txtMaterial3.Text)
BMB.Current("Material4") = Trim(txtMaterial4.Text)
BMB.Current("Last1") = Trim(txtLast1.Text) '--> this TextBox.Text got cleared
BMB.Current("Quantity") = Trim(txtQuantity.Text)
BMB.Current("Remark") = Trim(txtRemark.Text)
BMB.EndCurrentEdit()


anyone ever had similar experience?
could anyone tell me why did it happen?
why it only occured when DataSet1.Tables("DETAIL") already has a record or more?
why only TWO TextBoxes are affected by this strange behavior?

thanks
0
Comment
Question by:yukimura
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
7 Comments
 
LVL 9

Expert Comment

by:Wim_Bl
ID: 13529020
Hi,

are they bound to your BMB in another way then the others ? The AddNew might result in clearing the boxes to put the data for the new records in them. Just a thought though...

greetings
0
 
LVL 1

Expert Comment

by:BClements
ID: 13530748
What is the first BMB.EndCurrentEdit() before BMB.Add()? - just curious, I don't know if that affects anything or not.

I second Wim_Bl, how are the unaffected controls bound?

When I use BMB.AddNew() all the controls bound to that dataset are cleared and waiting for new input.  
BMB.EndCurrentEdit()  is called when the user clicks on the Update button after the new data is input.
0
 

Author Comment

by:yukimura
ID: 13538252
Wim_Bl,
the TextBoxes are not bound to anything
the Dataset table is set as the datasource for my datagrid, but this is not supposed to affect the TextBoxes

BClements,
as far as i know, BMB.EndCurrentEdit() is used to end any current edit on the dataset table
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 1

Expert Comment

by:BClements
ID: 13539231
Are the two textboxes that are changing bound to the dataset?  If so, you can try unbinding them so they are like the other text boxes and see if that works.
0
 

Author Comment

by:yukimura
ID: 13545896
BClements,
No all the textboxes (the ones that got cleared and the ones that are fine) are not bind to anything

i did set the DataSet Table as the DataSource for a DataGrid and as DataView... but it should not affect the textboxes... this is weird

because of this glitch, i have to set the value of my cleared textboxes (only 2 out of 8) to local variables before the call to BMB.AddNew()
then set them back to those textboxes after i add a record.

oh well did anyone ever got this kind of problem?
0
 
LVL 1

Accepted Solution

by:
BClements earned 400 total points
ID: 13560845
Maybe the problem lies in the BindingContextManager.  If your controls are not bound, then I don't see why you are using it.  

Maybe you will get the result you want by just using the table and row methods instead of the BindingContextManager.
0
 

Author Comment

by:yukimura
ID: 13562123
BClements,
maybe you are right

i use the BindingContextManager to navigate the records in Dataset Table
but the textboxes are not bound to BindingContextManager, thus it should not cleared the TextBoxes... even if it does, it should cleared all the TextBoxes not just 2 out of 8

but anyway i just save the values of those 2 textboxes to a local variables then set the values back to them after the call to AddNew

thanks
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question