Value of Bound Control Won't Stick w/o Change in Row

  • Thread starter Thread starter michael
  • Start date Start date
M

michael

I have a form with a DataGrid and a TextBox bound to the
same table in a DataSet(there is nothing else on the form
for the sake of simplicity). The textbox displays a field
not visually represented on the datagrid (the data is
just viewed better this way). I have found that if I type
a new value in the textbox, the value won't be
immediately saved to the table in the DataSet unless I
first click on a cell on the datagrid.

I assumed that anything typed into a bound control is
stored in the table in the dataset immediately. Why is
this not happening?


Michael
 
Hi Michael,

I'm not quite sure about your question. Are you just adding a new row in
the DataGrid and Textbox or modifying a record?

The new value might not be saved into data source immediately before
leaving that row, because DataRow.EndEdit() hasn't been called.

If anything is unclear, please feel free to reply to the post.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

--------------------
| Content-Class: urn:content-classes:message
| From: "michael" <[email protected]>
| Sender: "michael" <[email protected]>
| Subject: Value of Bound Control Won't Stick w/o Change in Row
| Date: Thu, 6 Nov 2003 12:38:38 -0800
| Lines: 16
| Message-ID: <[email protected]>
| MIME-Version: 1.0
| Content-Type: text/plain;
| charset="iso-8859-1"
| Content-Transfer-Encoding: 7bit
| X-Newsreader: Microsoft CDO for Windows 2000
| Thread-Index: AcOkpfUyOQ9RHn3SSdOMcS30OmnD6w==
| X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
| Newsgroups: microsoft.public.dotnet.framework.adonet
| Path: cpmsftngxa06.phx.gbl
| Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework.adonet:65680
| NNTP-Posting-Host: TK2MSFTNGXA13 10.40.1.165
| X-Tomcat-NG: microsoft.public.dotnet.framework.adonet
|
| I have a form with a DataGrid and a TextBox bound to the
| same table in a DataSet(there is nothing else on the form
| for the sake of simplicity). The textbox displays a field
| not visually represented on the datagrid (the data is
| just viewed better this way). I have found that if I type
| a new value in the textbox, the value won't be
| immediately saved to the table in the DataSet unless I
| first click on a cell on the datagrid.
|
| I assumed that anything typed into a bound control is
| stored in the table in the dataset immediately. Why is
| this not happening?
|
|
| Michael
|
|
 
Modifiying an existing record.

Should I call .EndEdit from within a Changed event to get
the effect that I want?


Michael
 
In the Form Closing event I use code like this to "move off the current row"
which forces a Save of the data.
(It is an old Access trick and seems to work in .Net too.)

DataGrid1.CurrentCell = New DataGridCell(DataGrid1.CurrentCell.RowNumber +
1, DataGrid1.CurrentCell.ColumnNumber)
 
Hi Michael,

If you need to call DataRow.EndEdit() explicitly, you have to put the code
in an event handler of a button or some other controls. I don't think you
would like that. You can try Joe's suggestion to move to another cell as
the current cell.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

--------------------
| From: "Joe Fallon" <[email protected]>
| References: <[email protected]>
<[email protected]>
<[email protected]>
| Subject: Re: Value of Bound Control Won't Stick w/o Change in Row
| Date: Thu, 6 Nov 2003 23:18:30 -0500
| Lines: 94
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
| Message-ID: <#[email protected]>
| Newsgroups: microsoft.public.dotnet.framework.adonet
| NNTP-Posting-Host: syr-24-92-252-181.twcny.rr.com 24.92.252.181
| Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP09.phx.gbl
| Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework.adonet:65715
| X-Tomcat-NG: microsoft.public.dotnet.framework.adonet
|
| In the Form Closing event I use code like this to "move off the current
row"
| which forces a Save of the data.
| (It is an old Access trick and seems to work in .Net too.)
|
| DataGrid1.CurrentCell = New DataGridCell(DataGrid1.CurrentCell.RowNumber
+
| 1, DataGrid1.CurrentCell.ColumnNumber)
|
| --
| Joe Fallon
|
|
|
|
| | > Modifiying an existing record.
| >
| > Should I call .EndEdit from within a Changed event to get
| > the effect that I want?
| >
| >
| > Michael
| >
| > >-----Original Message-----
| > >Hi Michael,
| > >
| > >I'm not quite sure about your question. Are you just
| > adding a new row in
| > >the DataGrid and Textbox or modifying a record?
| > >
| > >The new value might not be saved into data source
| > immediately before
| > >leaving that row, because DataRow.EndEdit() hasn't been
| > called.
| > >
| > >If anything is unclear, please feel free to reply to the
| > post.
| > >
| > >Kevin Yu
| > >=======
| > >"This posting is provided "AS IS" with no warranties,
| > and confers no
| > >rights."
| > >
| > >--------------------
| > >| Content-Class: urn:content-classes:message
| > >| From: "michael" <[email protected]>
| > >| Sender: "michael" <[email protected]>
| > >| Subject: Value of Bound Control Won't Stick w/o Change
| > in Row
| > >| Date: Thu, 6 Nov 2003 12:38:38 -0800
| > >| Lines: 16
| > >| Message-ID: <[email protected]>
| > >| MIME-Version: 1.0
| > >| Content-Type: text/plain;
| > >| charset="iso-8859-1"
| > >| Content-Transfer-Encoding: 7bit
| > >| X-Newsreader: Microsoft CDO for Windows 2000
| > >| Thread-Index: AcOkpfUyOQ9RHn3SSdOMcS30OmnD6w==
| > >| X-MimeOLE: Produced By Microsoft MimeOLE
| > V5.50.4910.0300
| > >| Newsgroups: microsoft.public.dotnet.framework.adonet
| > >| Path: cpmsftngxa06.phx.gbl
| > >| Xref: cpmsftngxa06.phx.gbl
| > microsoft.public.dotnet.framework.adonet:65680
| > >| NNTP-Posting-Host: TK2MSFTNGXA13 10.40.1.165
| > >| X-Tomcat-NG: microsoft.public.dotnet.framework.adonet
| > >|
| > >| I have a form with a DataGrid and a TextBox bound to
| > the
| > >| same table in a DataSet(there is nothing else on the
| > form
| > >| for the sake of simplicity). The textbox displays a
| > field
| > >| not visually represented on the datagrid (the data is
| > >| just viewed better this way). I have found that if I
| > type
| > >| a new value in the textbox, the value won't be
| > >| immediately saved to the table in the DataSet unless I
| > >| first click on a cell on the datagrid.
| > >|
| > >| I assumed that anything typed into a bound control is
| > >| stored in the table in the dataset immediately. Why is
| > >| this not happening?
| > >|
| > >|
| > >| Michael
| > >|
| > >|
| > >
| > >.
| > >
|
|
|
 
I added this code snippet in an event that is fired
before the form displays new information. It works with
the forms CurrencyManager:

CType(Me.TheCurrMan.Current, DataRowView).EndEdit()

Seems to work OK. Any other suggestions? Thanks for the
advice.

Michael

-----Original Message-----
In the Form Closing event I use code like this to "move off the current row"
which forces a Save of the data.
(It is an old Access trick and seems to work in .Net too.)

DataGrid1.CurrentCell = New DataGridCell
(DataGrid1.CurrentCell.RowNumber +
 
I added this code snippet in an event that is fired
before the form displays new information. It works with
the form's CurrencyManager:

CType(Me.TheCurrMan.Current, DataRowView).EndEdit()

Seems to work OK. Any other suggestions? Thanks for the
advice.

Michael
 
Back
Top