Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / ADO.NET / March 2004

Tip: Looking for answers? Try searching our database.

textbox databind problem

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Oka Morikawa - 03 Mar 2004 20:37 GMT
I have DataSet with two DataTable and DataRelation between them.
I have two DataGrids with master / detail style and additional textbox which
are bind to detail table.

ds.Tables.Add(tableCompany);
ds.Tables.Add(tableBranch);
ds.Relations.Add("Branch",
ds.Tables["Company"].Columns["CompanyID"],
ds.Tables["Branch"].Columns["CompanyID"]);

this.gridCompany.SetDataBinding(ds.Tables["Company"], "");
this.gridBranch.SetDataBinding(ds.Tables["Company"], "Branch");

this.tbCode.DataBindings.Add("Text", ds.Tables["Company"], "Branch.Code");
this.tbStreet.DataBindings.Add("Text", ds.Tables["Company"],
"Branch.Street");

Now if I update textbox tbCode of tbStreet and then click the update button
which updates DT changes back to database nothing happens BUT if I after
updating TextBox click the DG then it will update changes back to DB.

How do I make so that the TextBox will update the DT immediately it loses
focus? Do I need to use some refreshing code on TextBox.Leave event? Or some
additional code on my Update button?

Thanks,
Oka Morikawa
Rajesh Patel - 04 Mar 2004 01:40 GMT
on your update button click add following code, before you call update on
database.

vb.net syntax
me.bindingcontext(ds.tables("company"), "").endcurrentedit()

c# syntax
this.bindingcontext(ds.tables["Company"], "").endcurrentedit()

Syntax may not be exact. you might need to change little bit.

The purpose is, your record is in edit mode, so take it out from edit mode
by calling endcurrentedit method.

hope this helps,

Rajesh Patel

> I have DataSet with two DataTable and DataRelation between them.
> I have two DataGrids with master / detail style and additional textbox which
[quoted text clipped - 23 lines]
> Thanks,
> Oka Morikawa
Oka Morikawa - 04 Mar 2004 11:36 GMT
Great!
Thought syntax didn't work but it was easy to figure out and my final
solution was:

  BindingManagerBase xCurrent =
   (CurrencyManager) BindingContext[ds.Tables["Company"], ""];
  xCurrent.EndCurrentEdit();

> on your update button click add following code, before you call update on
> database.
[quoted text clipped - 44 lines]
> > Thanks,
> > Oka Morikawa

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.