Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Databinding problem

Status
Not open for further replies.

litton1

Technical User
Apr 21, 2005
584
GB
Hi all, my problem is that when I use the following code and then increment the Position property in BindingSource by using a nextButton (see below), the records in the textbox’s don’t update to the next record in the DataTable?

On Load
Code:
// this displays the first record :)
this.personTableBindingSource.DataSource = dtPerson; //DataTable
this.textboxPersonID.DataBindings.Add("Text", dtPerson, "PersonID");
this.textboxFirstname.DataBindings.Add("Text", dtPerson, "FirstName");
this.textboxLastname.DataBindings.Add("Text", dtPerson, "LastName");

Next Button Click
Code:
if (this.personTableBindingSource.Position < this.personTableBindingSource.Count - 1)
{
  // I get Here but no update happens 
  // in Textboxes? I thought textboxes
  // would show 2nd record in DT but no change?
  this.personTableBindingSource.Position += 1;
}
I thought that this would update the textboxes?
What am I doing wrong? Any help Appreciated, thx T

Age is a consequence of experience
 
ok solved it!
the textbox binding should be bound to the binding source not the DataTable. Makes sense...
Code:
this.textboxPersonID.DataBindings.Add("Text", personTableBindingSource, "PersonID");

Age is a consequence of experience
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top