|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
DataBinding with Unbound Columns and calling EndCurrentEditsection 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. 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 Show quoteHide quote "Aspnot" <NOSPAM_Aspnot_NOSPAM@nc.rr.com> schreef in bericht news:1A282540-28B6-47F8-9F7F-C6A563F6D260@microsoft.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. 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. Show quoteHide quote "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" <NOSPAM_Aspnot_NOSPAM@nc.rr.com> schreef in bericht > news:1A282540-28B6-47F8-9F7F-C6A563F6D260@microsoft.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. > > > 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 Show quoteHide quote "Aspnot" <NOSPAM_Aspnot_NOSPAM@nc.rr.com> schreef in bericht news:11B08403-6CDF-4E00-9FBB-22C77C3F52CA@microsoft.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" <NOSPAM_Aspnot_NOSPAM@nc.rr.com> schreef in bericht >> news:1A282540-28B6-47F8-9F7F-C6A563F6D260@microsoft.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. >> >> >>
More VS2003 to VS2005 questions
Write to an XML file using data from an SQLserver table Master Page Template difference between imports-implements-inherits ListBox Problem firing a dts package's execution How To Show Partial Classes as a Hierarchy in Solution Explorer? new line in datagrid cell Dang, trivial problem! newbie script question |
|||||||||||||||||||||||