Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Change text of databound textbox programatically not creating Proposed version of data

Posted on 2003-11-13
5
Medium Priority
?
608 Views
Last Modified: 2012-05-04
This is a little esoteric. I have a text box control (txtbox1) bound to a dataset.  I am setting the .text property programmatically based on user interaction with another control.  The text box is on a TabPage (tabpage1).  When I set the text programmatically, navigate to TabPage2, and then return to the TabPage1,  the textbox reverts to the original text.  After changing the text programmatically if I test for myDataSet.myTable(0).myrow(currentrow)("FieldName",DataRowVersion.Proposed) I get a message that there is no proposed value.
 If I type the change by hand  I return the new value as proposed, and I don't lose the new value between navigation of the tabspages.  I would like to get the programmatic value to set a proposed value so that I still have the option of rejecting the change to the dataset, without having to write my own sub to manage this.  
Any ideas how to get the programmed text the register as having changed?  I tried setting the .modified property to True this did not work.
Is there a way to work directly with the data set to set a value as proposed while maitaining a record of the original value?  
thanks in advance
Tom Majarov  
0
Comment
Question by:tmajarov
[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
  • 2
  • 2
5 Comments
 
LVL 4

Expert Comment

by:NetPointer
ID: 9742154
If you BIND your dataset with your textbox instead of manually assigning the .text property, you will get your desired results.
0
 
LVL 4

Expert Comment

by:NetPointer
ID: 9742161
Me.TextBox1.DataBindings.Add("Text",dataset.datatable,"FieldName")
0
 

Author Comment

by:tmajarov
ID: 9742244
Dear NetPointer,
The text box is bound - it displays an initial value from the dataset.  I am trying to edit the text, and the thereby the intial value from the dataset by passing a value derived from the another control, for example a listbox, to the text property of the text box.   I can change the value in the dataset directly: for example

mydataset.tables(0).rows(0)("myField") = myListBox.SelectedText  

- but this then become the current value in the dataset and cannot be undone with a cancelcurrentedit call against the bindingcontext for the table.  
0
 

Accepted Solution

by:
tmajarov earned 0 total points
ID: 9742536
O.K. I think I just figured out how to do what I need to do.  I will not be awarding points for answers.  I am presenting the solution here, the moderators can decide whether or not to remove the question.  The solution my be helpful to others.


     Dim myRow As DataRow = myDataset.Tables("myTable").Rows(0)
     myRow.BeginEdit()
     myRow("myField") = strText
    TextBox1.Text = myRow("myField", DataRowVersion.Proposed)

This allows the new value (strText) to be listed as a propsed value in the dataset, and then sets the text in TextBox1 to this value.  It also allows the TextBox1.text to revert to the original value when CancelCurrentEdit is called against the BindingContext.
0

Featured Post

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Question has a verified solution.

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

Flash (http://en.wikipedia.org/wiki/Adobe_Flash) has evolved over the years to where it has become a masterful tool for displaying content screen.  It has excellent layout placement, UI precision as well as rendering capabilities. This, along with t…
For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
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…

721 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