Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I have windows form control bound to a business object. Upon initialization it displays the data from the business object in the text box as its bound. But when I update the vale in the text box the respective data member of my business object doesnt get updated.

 

Any suggestions please?

 

Thanks

Posted

The usual reason for that to happen is that your textbox is still in edit mode when the update is donne...

 

The following line should solve your problem:

 

Me.BindingContext(DataSourceObject).EndCurrentEdit()

 

Alex :p

Software bugs are impossible to detect by anybody except the end user.
Posted
Thaks a lot for your help,

 

But I wanted to know where should I place this line. and what is teh dataSource object?

 

Put it just before you call the update method.

The DataSource is the main object where the data comes from... (your business object)

Software bugs are impossible to detect by anybody except the end user.
Posted

oops!

I think I am lacking some basoc concepts here. SO I call the endCurrentEdit() method as advised by you.

But, I dont have any update method, So here is what my understanding is.. I bind a control to a property in my business object

Label1.databindings.Add("Text",myPropertyBean,"Name")

 

SO the value returned by the Name property would appear in the text of the Label1.

Now some other UI component changes this text of Label1.....and I expected that automatically the setter for Name property would be called and the appropriate member variable in my 'myPropertyBean' would be updated

 

but I thought This would happen AUTOMATICALLY as its databound.

 

Do i have to manually call this setter method instead as a part of the update method you were talking about??

 

Sorry for being confusing if I am...

 

Thanks again

!!

Posted

Sometimes databinding doesn't work quite the way we expected it to.

Mostly because, sometimes, the UI objects don't end up their edit mode.

 

So... if you need to change the value in other way that directly typing on the textbox do it directly on the data source object... as databound it will show on the textbox.

 

Otherwise, try to EndCurrentEdit when loosing focus or something...

 

Note:

Keep in mind that, i.e. on a databound textbox, the data is only bound when the edit process is finished, not every time you type something on... If the control doesn't end the edit properlly, you will never have your data sync donne.

Software bugs are impossible to detect by anybody except the end user.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...