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

Re: textbox databind problem by Rajesh

Rajesh
Wed Mar 03 19:40:15 CST 2004

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


"Oka Morikawa" <oka@digine.comX> wrote in message
news:uyPaL8VAEHA.1468@tk2msftngp13.phx.gbl...
> 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
>
>



Re: textbox databind problem by Oka

Oka
Thu Mar 04 05:36:39 CST 2004

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();

"Rajesh Patel" <rdp647@hotmail.com> wrote in message
news:OW3SCmYAEHA.2808@TK2MSFTNGP10.phx.gbl...
> 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
>
>
> "Oka Morikawa" <oka@digine.comX> wrote in message
> news:uyPaL8VAEHA.1468@tk2msftngp13.phx.gbl...
> > 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
> >
> >
>
>