Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 856377
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T08:13:30+00:00 2026-05-15T08:13:30+00:00

I got a textbox and use databinding to an object. This works fine, until

  • 0

I got a textbox and use databinding to an object. This works fine, until I try to select a new product:

product = new Product(id);
textbox.DataBindings.Add("Text", product, "ProductName");

// After user action:
product = new Product(newId); // <- the textbox isn't updated

Do I have to clear the databinding and set it again after the product is updated?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T08:13:30+00:00Added an answer on May 15, 2026 at 8:13 am

    In short: Yes, you have to re-establish the DataBinding, cause the TextBox has a reference to the old object.

    But to make this a little more robust, you should maybe use a BindingSource for your DataBinding. To get this to work, you should open your form in design view.

    • Select your TextBox and open the Properties window
    • Look into category Data and click on the cross to the left of the (DataBindings) property
    • Click on the drop down button next to the Text property
    • In the drop down list select Add project data source
    • From the wizard select Object and in the next your object type

    Now you’ll get a new object in your form (e.g. productBindingSource), that is bound to the text of your TextBox. Last but not least you have to attach your object by using the following code:

    productBindingSource.DataSource = product;
    

    But also this solution doesn’t help against a re-binding, but all you have to do now is:

    product = new Product();
    productBindingSource.DataSource = product;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got this textBox which triggers off an ajax request using jQuery: <asp:TextBox ID=postcodeTextBox
I've got a select with two 'special' options, a bit like this: <select> <option
I've got a TextBox on a form that I am using to just display
I've got a textbox being used to enter a password inside a wizard control.
I have got a textbox on a form with a method being called from
I'm using the jQuery Validation plugin and I've got a textbox with the class
I'm working on a WPF MVVM application and I've got a TextBox on my
I've got a multiline textBox that I would like to have a label on
Hi im making a custom Textbox i got everty thing working but how do
I've got a simple little WPF app with a TextBox and a WebBrowser control.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.