473,396 Members | 1,997 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

DataBinding with Unbound Columns and calling EndCurrentEdit

I have a form that is setup in a Master/Detail configuration. The Detail
section is represented with a DataGridView. Some of the columns in this
DataGridView control are unbound.

When a user clicks the Cancel button, I loop through the tables in my
DataSet and call EndCurrentEdit() to determine if HasChanges() is True. And
then prompt the user and allow them to Cancel out of the exit. If the user
chooses Cancel and any changes have been made to the Master table in the
DataSet, my unbound columns lose their data due to the fact that I called
EndCurrentEdit() on the Master table.

These Unbound columns come from my database, so I would rather not have to
reload them in this scenario.

Do I have to reload them? Is there a way to halt them from getting
refreshed? If not, what is the best event to react to to reload the
information?

PS - I realize that I can add these fields to my DataSet, but I would rather
not have to do that. This application is currently set to run locally, but
this company has a remote office that we may link in through web services and
I would hate to have that extra overhead for every save.
Jun 20 '06 #1
3 2962
ASPNOT,

Are you sure of that, did you save your table in a Session (or somewhere
else) and have set it back using the load of your form in the isPostBack
situation?

Cor

"Aspnot" <NO******************@nc.rr.com> schreef in bericht
news:1A**********************************@microsof t.com...
I have a form that is setup in a Master/Detail configuration. The Detail
section is represented with a DataGridView. Some of the columns in this
DataGridView control are unbound.

When a user clicks the Cancel button, I loop through the tables in my
DataSet and call EndCurrentEdit() to determine if HasChanges() is True.
And
then prompt the user and allow them to Cancel out of the exit. If the
user
chooses Cancel and any changes have been made to the Master table in the
DataSet, my unbound columns lose their data due to the fact that I called
EndCurrentEdit() on the Master table.

These Unbound columns come from my database, so I would rather not have to
reload them in this scenario.

Do I have to reload them? Is there a way to halt them from getting
refreshed? If not, what is the best event to react to to reload the
information?

PS - I realize that I can add these fields to my DataSet, but I would
rather
not have to do that. This application is currently set to run locally,
but
this company has a remote office that we may link in through web services
and
I would hate to have that extra overhead for every save.

Jun 21 '06 #2
Thanks for the reply, Cor.

This is a VB form, not an ASP.NET form. Sorry for not specifying that.

I have put a bandaid on this by simply reloading the unbound fields after
the call to EndCurrentEdit(). I don't like making all of these extra calls
to the database, but I had to get something in place so I could keep moving
forward with this application I am working on.

Any thoughts on another way to deal with this?

PS - In some of my reading yesterday, I found a statement that fit why this
is happening. I thought I knew why, but wanted to see it written somewhere.
If the DataTable has any changes, the data in the DataSet is refreshed, which
causes the bound controls to also be refreshed. Also, any related tables are
also refreshed which explains why my DataGridView data is being refreshed.

"Cor Ligthert [MVP]" wrote:
ASPNOT,

Are you sure of that, did you save your table in a Session (or somewhere
else) and have set it back using the load of your form in the isPostBack
situation?

Cor

"Aspnot" <NO******************@nc.rr.com> schreef in bericht
news:1A**********************************@microsof t.com...
I have a form that is setup in a Master/Detail configuration. The Detail
section is represented with a DataGridView. Some of the columns in this
DataGridView control are unbound.

When a user clicks the Cancel button, I loop through the tables in my
DataSet and call EndCurrentEdit() to determine if HasChanges() is True.
And
then prompt the user and allow them to Cancel out of the exit. If the
user
chooses Cancel and any changes have been made to the Master table in the
DataSet, my unbound columns lose their data due to the fact that I called
EndCurrentEdit() on the Master table.

These Unbound columns come from my database, so I would rather not have to
reload them in this scenario.

Do I have to reload them? Is there a way to halt them from getting
refreshed? If not, what is the best event to react to to reload the
information?

PS - I realize that I can add these fields to my DataSet, but I would
rather
not have to do that. This application is currently set to run locally,
but
this company has a remote office that we may link in through web services
and
I would hate to have that extra overhead for every save.


Jun 21 '06 #3
ASPNOT,

I tried it like this, but everything is as I expect.

\\\
Public Class Form1
Private dt As New DataTable
Private Sub Form1_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
Dim strConn As String = _
"Server = .\SQLEXPRESS;Database = NorthWind; Integrated Security =
SSPI;"
Dim conn As New SqlClient.SqlConnection(strConn)
Dim da As New SqlClient.SqlDataAdapter("Select * from orders", conn)
da.Fill(dt)
dt.Columns(2).ColumnMapping = MappingType.Hidden
dt.Rows(0)(2) = 12
DataGridView1.DataSource = dt
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click
DirectCast(BindingContext(dt), CurrencyManager).EndCurrentEdit()
dt.Columns(2).ColumnMapping = MappingType.Element
DataGridView1.DataSource = Nothing
DataGridView1.DataSource = dt
DataGridView1.Refresh()
End Sub
End Class
///

I hope this helps,
Cor

"Aspnot" <NO******************@nc.rr.com> schreef in bericht
news:11**********************************@microsof t.com...
Thanks for the reply, Cor.

This is a VB form, not an ASP.NET form. Sorry for not specifying that.

I have put a bandaid on this by simply reloading the unbound fields after
the call to EndCurrentEdit(). I don't like making all of these extra
calls
to the database, but I had to get something in place so I could keep
moving
forward with this application I am working on.

Any thoughts on another way to deal with this?

PS - In some of my reading yesterday, I found a statement that fit why
this
is happening. I thought I knew why, but wanted to see it written
somewhere.
If the DataTable has any changes, the data in the DataSet is refreshed,
which
causes the bound controls to also be refreshed. Also, any related tables
are
also refreshed which explains why my DataGridView data is being refreshed.

"Cor Ligthert [MVP]" wrote:
ASPNOT,

Are you sure of that, did you save your table in a Session (or somewhere
else) and have set it back using the load of your form in the isPostBack
situation?

Cor

"Aspnot" <NO******************@nc.rr.com> schreef in bericht
news:1A**********************************@microsof t.com...
>I have a form that is setup in a Master/Detail configuration. The
>Detail
> section is represented with a DataGridView. Some of the columns in
> this
> DataGridView control are unbound.
>
> When a user clicks the Cancel button, I loop through the tables in my
> DataSet and call EndCurrentEdit() to determine if HasChanges() is True.
> And
> then prompt the user and allow them to Cancel out of the exit. If the
> user
> chooses Cancel and any changes have been made to the Master table in
> the
> DataSet, my unbound columns lose their data due to the fact that I
> called
> EndCurrentEdit() on the Master table.
>
> These Unbound columns come from my database, so I would rather not have
> to
> reload them in this scenario.
>
> Do I have to reload them? Is there a way to halt them from getting
> refreshed? If not, what is the best event to react to to reload the
> information?
>
> PS - I realize that I can add these fields to my DataSet, but I would
> rather
> not have to do that. This application is currently set to run locally,
> but
> this company has a remote office that we may link in through web
> services
> and
> I would hate to have that extra overhead for every save.


Jun 22 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Jeff | last post by:
I am having a behaviour problem with Databinding on a C# WinForm. I have three textboxes and a Checkbox bound to a dataset. The desired behaviour is when I check/uncheck the checkbox, I want to...
9
by: Marina | last post by:
Here is the problem. If 2 different properties on the same (or different) control are bound to the same data column, changing the Text property and calling EndCurrentEdit discards the new value. ...
3
by: Krzysiek | last post by:
Hi, I have a few textboxes on a form bound (using .text property) to DataSet. When I change values in textboxes and then check DataSet.HaveChanges method I get 'false' Does it mean that data...
0
by: Steve McLellan | last post by:
Hi, I've poked around for a solution to this with no luck, though I think it's come up before. Given a simple DataBinding that has an associated OnChanged event, everything works fine bound...
0
by: Steve | last post by:
Hello I've got a databinding problem which occurs when I call EndCurrentEdit. For some reason the bound control (a combobox) reverts to a previous value, and not the one I have just set. The...
0
by: Tonny Steen | last post by:
Hi All! When I apply a databinding to the Tag property of a textbox the row gets Modified state when calling the EndCurrentEdit method even if no changes are made. When the databinding of the...
2
by: Agnes | last post by:
Now, I understand my problem (bugs?) about the Tab Control & dataBinding 1)a simple blank form with tabcontrol , there are 2 pages, pages1 got 3 textboxes (txtShipperNAme,txtJobNo,txtVslName) and...
1
by: Gary Shell | last post by:
I have a pair of combo boxes on a form. Both have their SelectedValue property bound to a column on a table called "Input_Output". One column is called "Class" and the second is called "SubClass"....
7
by: Vlado Jasovic | last post by:
Hello, I'm using typed dataset for databinding to windows controls and I'm having some problems. I'm trying to move all business logic to datatable column_changing events and the problem that...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.