Re: databinding problem

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Robin,

I'm using Column_Changing mostly to validate input.
In this case, Column_Changing should change different column depending on
current column's value.

I know about BindingSource and I'm using BindingManager but that's on form
level.

I didn't find a way to force databinding update from a datatable except as a
workaround with raising Event as described.

Also, I do use n-tier model but Business and Data tier is contained in one
layer (Datasets/Datatable). All the validation/ updating datasource happens
here. This is acceptable scenario for us as we don't anticipate having
database source other than MSSQL and don't have problem with BusinessObjects
and DataLayer not being loosely coupled.


Again, the only problem is how to force Databinding, EndCurrentEdit from
Datatable.



"RobinS" <RobinS@xxxxxxxxxxxxxxx> wrote in message
news:FradnVkz7p5gCSPYnZ2dnUVZ_ruknZ2d@xxxxxxxxxxxxxx
Why are you using the Column_Changing events? Just a masochist? In my
experience, events never work the way you think they should in .Net, or in
the order you think they should.

Anyway, if I understand what you're doing, you're changing the data source
and the change is not reflected in the data displayed in the controls on
the screen that are bound to that data source.

Have you checked out the BindingSource? It is an intermediary between your
controls and your data source, and immediately reflects any changes made
to the data source in the controls. To push it the other way, you invoke
EndEdit. Then of course, you have to call Update on your adapter to push
the changes down to the data source.

So you add a Binding Source (add the component to your form from the Data
toolbox).

Set the data source of it to your data table.

myBindingSource.DataSource = myDataTable

Then bind your controls to the BindingSource.

myTextBox.DataBindings.Add(new Binding("Text", _
myBindingSource, "CompanyName", true))

myGrid.DataSource = myBindingSource

See if that gets you anywhere. And answer my question at the top; maybe I
can recommend another solution.

I use the n-layer model, so all of the data I display on the screen is
defined in Classes. I capture changes to them when the Property value is
modified.

Robin S.
-------------------------------------------------
"Vlado Jasovic" <vladoDOTjasovicATexcelleincDOTcom> wrote in message
news:kaidnc0JGflb7CPYnZ2dnUVZ_ualnZ2d@xxxxxxxxxxxxxxx
Still need an answer.

I made a workaround by creating an event under datatable and form
subscribes to it and calls BindingManager.EndCurrentEdit but would like
to know if there's another way.

Thanks,

Vlado


"RobinS" <RobinS@xxxxxxxxxxxxxxx> wrote in message
news:eOqdnQGuUNt2eibYnZ2dnUVZ_vKunZ2d@xxxxxxxxxxxxxx
Did you figure out the answer to this, or are you still hanging?
Because I have a pretty good idea, if you still need an answer...

Robin S.
---------------------------
"Vlado Jasovic" <vladoDOTjasovicATexcelleincDOTcom> wrote in message
news:rpGdnY53H6YTjSfYnZ2dnUVZ_qunnZ2d@xxxxxxxxxxxxxxx
VB.Net 2005 and Datatable/TableAdapter.

"RobinS" <RobinS@xxxxxxxxxxxxxxx> wrote in message
news:9aWdnXsb8c_UoiTYnZ2dnUVZ_uuqnZ2d@xxxxxxxxxxxxxx
Which version of .Net are you using? 2003 or 2005?

Robin S.
------------------------
"Vlado Jasovic" <vladoDOTjasovicATexcelleincDOTcom> wrote in message
news:4LudnUybUJhDdiXYnZ2dnUVZ_uWlnZ2d@xxxxxxxxxxxxxxx
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 I'm having is when I change some other
column, control value doesn't update immediately until I call
endcurrentedit on bindingmanager which doesnt happen until user click
update button.

Here's my problem:

Private Sub BusinessPartnerDataTable_ColumnChanging(ByVal sender As
System.Object, ByVal e As System.Data.DataColumnChangeEventArgs)
Handles Me.ColumnChanging
Select Case e.Column.ColumnName

Case Me.dbaColumn.ColumnName

Me(0).categoryID = "changed_column"

End Select


End Sub


Now, unerlying dataset.datatable(0).categoryID is indeed changed but
databound textbox control remains the same.



How can I force databinding.update from dataset/datatable?



Thanks,



Vlado














.



Relevant Pages

  • Re: databinding problem
    ... Anyway, if I understand what you're doing, you're changing the data source ... controls and your data source, and immediately reflects any changes made to ... Then bind your controls to the BindingSource. ... Robin S. ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Clear DataGridview
    ... is a sample that illustrates how I'm populating a custom object, ... then using the ArrayList as my data source. ... Then the grid shows whatever the BindingSource displays. ...
    (microsoft.public.dotnet.framework.windowsforms.controls)
  • Re: databinding problem
    ... I've never used the Binding Manager; I always use a BindingSource because ... Robin S. ... controls on the screen that are bound to that data source. ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Binding a DataGridView in code
    ... I chose to use a bindingsource at design time. ... Since I have to move on decided to just put up a blank DataGridView and set ... Only those data source that implements the IBindingList interface can ... BindingListlists = this.dataGridView1.DataSource as ...
    (microsoft.public.dotnet.framework.windowsforms)
  • Re: DataGridView Cascading DataGridViewComboBoxColumn
    ... My basic thought is to bind the States column to a data source that has all ... BindingSource bsCountry = new BindingSource; ...
    (microsoft.public.dotnet.framework.windowsforms.controls)