473,898 Members | 3,274 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Databinding

Can someone explain to me the difference between these two bindings?

dim b as Binding

b=New Binding(dsMyDat aset.tblMyTable , "colMyColum n")

b=New Binding(dsMyDat aset, "tblMyTable.col MyColumn")

They produce different behavior in my application. I know which one I must
use, but I don't understand why.

Thanks for the help.
--
Pat
Nov 21 '05 #1
4 2214
This is the cool thing about Winforms databinding ;-). Currency managers are
what controls your binding to datasources but depending on the *path* you
take to that datasource you will end up with different currency manager
references, hence, different views into your data. This allows you to decide
whether controls should be syncronized or not to the same exact source
object. So for example if we set up controls like this:

Me.TextBox1.Dat aBindings.Add(" Text", MyDataset, "Customers.Cust omerID")
Me.TextBox2.Dat aBindings.Add(" Text", MyDataset, "Customers.Cust omerName")

You end up with both controls bound through the same Currency manager. You
can see this by taking a look at the Bindings collection:

Dim CM As CurrencyManager = DirectCast(Me.B indingContext(M yDataset,
"Customers" ), CurrencyManager )
Dim bindingsCount As Integer = CM.Bindings.Cou nt '-- returns 2

Now if we did this:

Me.TextBox1.Dat aBindings.Add(" Text", MyDataset, "Customers.Cust omerID")
Me.TextBox2.Dat aBindings.Add(" Text", MyDataset.Table s("Customers" ),
"CustomerNa me")

In this case you will end up with two completely separate Currency managers
because the *path* to your data source is different even though both
controls will be editing the same table, Customers.

Dim CM1 As CurrencyManager = DirectCast(Me.B indingContext(M yDataset,
"Customers" ), CurrencyManager )
Dim bindingsCount1 As Integer = CM1.Bindings.Co unt '-- returns 1

Dim CM2 As CurrencyManager =
DirectCast(Me.B indingContext(M yDataset.Tables ("Customers" )),
CurrencyManager )
Dim bindingsCount2 As Integer = CM2.Bindings.Co unt '-- returns 1

The a currency manager maintains a view of the datasource so you can easily
access the current DataView as well as the current DataRowView:

Dim dv As DataView = DirectCast(CM.L ist, DataView)
Dim dvr As DataRowView = DirectCast(CM.C urrent, DataRowView)

You can obtain currency managers for any table/path in your dataset even if
there are no control bindings set (in that case the Bindings.Count would be
0). Complex winforms databinding can take some practice, but once you get
the hang of it you can create some very cool forms.

-B

"pmcguire" <pm******@discu ssions.microsof t.com> wrote in message
news:8E******** *************** ***********@mic rosoft.com...
Can someone explain to me the difference between these two bindings?

dim b as Binding

b=New Binding(dsMyDat aset.tblMyTable , "colMyColum n")

b=New Binding(dsMyDat aset, "tblMyTable.col MyColumn")

They produce different behavior in my application. I know which one I
must
use, but I don't understand why.

Thanks for the help.
--
Pat

Nov 21 '05 #2
Yes, I agree that the ability to create multiple currency managers against
the same DataSource is a powerful tool (I am only now getting into it in my
application; and the doors it opens are very interesting); however, this
implementation smells a little like an unintended feature. As I read your
response, your ability to create these independent CurrencyManager s is
limited by the number of unique paths to the same data element you can come
up with. It seems like just an explicit declaration of "New
CurrencyManager ..." would be better.

As I said, I'm just now getting into this, so maybe I'm just not fully
appreciating the situation yet.

Thanks, though, for the explanation.

Pat

"Beth Massi [Architect MVP]" wrote:
This is the cool thing about Winforms databinding ;-). Currency managers are
what controls your binding to datasources but depending on the *path* you
take to that datasource you will end up with different currency manager
references, hence, different views into your data. This allows you to decide
whether controls should be syncronized or not to the same exact source
object. So for example if we set up controls like this:

Me.TextBox1.Dat aBindings.Add(" Text", MyDataset, "Customers.Cust omerID")
Me.TextBox2.Dat aBindings.Add(" Text", MyDataset, "Customers.Cust omerName")

You end up with both controls bound through the same Currency manager. You
can see this by taking a look at the Bindings collection:

Dim CM As CurrencyManager = DirectCast(Me.B indingContext(M yDataset,
"Customers" ), CurrencyManager )
Dim bindingsCount As Integer = CM.Bindings.Cou nt '-- returns 2

Now if we did this:

Me.TextBox1.Dat aBindings.Add(" Text", MyDataset, "Customers.Cust omerID")
Me.TextBox2.Dat aBindings.Add(" Text", MyDataset.Table s("Customers" ),
"CustomerNa me")

In this case you will end up with two completely separate Currency managers
because the *path* to your data source is different even though both
controls will be editing the same table, Customers.

Dim CM1 As CurrencyManager = DirectCast(Me.B indingContext(M yDataset,
"Customers" ), CurrencyManager )
Dim bindingsCount1 As Integer = CM1.Bindings.Co unt '-- returns 1

Dim CM2 As CurrencyManager =
DirectCast(Me.B indingContext(M yDataset.Tables ("Customers" )),
CurrencyManager )
Dim bindingsCount2 As Integer = CM2.Bindings.Co unt '-- returns 1

The a currency manager maintains a view of the datasource so you can easily
access the current DataView as well as the current DataRowView:

Dim dv As DataView = DirectCast(CM.L ist, DataView)
Dim dvr As DataRowView = DirectCast(CM.C urrent, DataRowView)

You can obtain currency managers for any table/path in your dataset even if
there are no control bindings set (in that case the Bindings.Count would be
0). Complex winforms databinding can take some practice, but once you get
the hang of it you can create some very cool forms.

-B

"pmcguire" <pm******@discu ssions.microsof t.com> wrote in message
news:8E******** *************** ***********@mic rosoft.com...
Can someone explain to me the difference between these two bindings?

dim b as Binding

b=New Binding(dsMyDat aset.tblMyTable , "colMyColum n")

b=New Binding(dsMyDat aset, "tblMyTable.col MyColumn")

They produce different behavior in my application. I know which one I
must
use, but I don't understand why.

Thanks for the help.
--
Pat


Nov 21 '05 #3
I didn't mention it in my first post, but you can create as many cm's to the
datasources as you want by creating different DataView references and bind
to them instead. So it isn't limited.

Dim dv1 As New DataView(myData Set.Table1)
Dim dv2 As New DataView(myData Set.Table1)
Dim dv3 As New DataView(myData Set.Table1)
Dim dv4 As New DataView(myData Set.Table1)
Dim dv5 As New DataView(myData Set.Table1)
'-- These will be different currency managers
Dim cm1 As CurrencyManager = DirectCast(Me.B indingContext(d v1),
CurrencyManager )
Dim cm2 As CurrencyManager = DirectCast(Me.B indingContext(d v2),
CurrencyManager )
Dim cm3 As CurrencyManager = DirectCast(Me.B indingContext(d v3),
CurrencyManager )
Dim cm4 As CurrencyManager = DirectCast(Me.B indingContext(d v4),
CurrencyManager )
Dim cm5 As CurrencyManager = DirectCast(Me.B indingContext(d v5),
CurrencyManager )

"pmcguire" <pm******@discu ssions.microsof t.com> wrote in message
news:97******** *************** ***********@mic rosoft.com...
Yes, I agree that the ability to create multiple currency managers against
the same DataSource is a powerful tool (I am only now getting into it in
my
application; and the doors it opens are very interesting); however, this
implementation smells a little like an unintended feature. As I read your
response, your ability to create these independent CurrencyManager s is
limited by the number of unique paths to the same data element you can
come
up with. It seems like just an explicit declaration of "New
CurrencyManager ..." would be better.

As I said, I'm just now getting into this, so maybe I'm just not fully
appreciating the situation yet.

Thanks, though, for the explanation.

Pat

"Beth Massi [Architect MVP]" wrote:
This is the cool thing about Winforms databinding ;-). Currency managers
are
what controls your binding to datasources but depending on the *path* you
take to that datasource you will end up with different currency manager
references, hence, different views into your data. This allows you to
decide
whether controls should be syncronized or not to the same exact source
object. So for example if we set up controls like this:

Me.TextBox1.Dat aBindings.Add(" Text", MyDataset, "Customers.Cust omerID")
Me.TextBox2.Dat aBindings.Add(" Text", MyDataset, "Customers.Cust omerName")

You end up with both controls bound through the same Currency manager.
You
can see this by taking a look at the Bindings collection:

Dim CM As CurrencyManager = DirectCast(Me.B indingContext(M yDataset,
"Customers" ), CurrencyManager )
Dim bindingsCount As Integer = CM.Bindings.Cou nt '-- returns 2

Now if we did this:

Me.TextBox1.Dat aBindings.Add(" Text", MyDataset, "Customers.Cust omerID")
Me.TextBox2.Dat aBindings.Add(" Text", MyDataset.Table s("Customers" ),
"CustomerNa me")

In this case you will end up with two completely separate Currency
managers
because the *path* to your data source is different even though both
controls will be editing the same table, Customers.

Dim CM1 As CurrencyManager = DirectCast(Me.B indingContext(M yDataset,
"Customers" ), CurrencyManager )
Dim bindingsCount1 As Integer = CM1.Bindings.Co unt '-- returns 1

Dim CM2 As CurrencyManager =
DirectCast(Me.B indingContext(M yDataset.Tables ("Customers" )),
CurrencyManager )
Dim bindingsCount2 As Integer = CM2.Bindings.Co unt '-- returns 1

The a currency manager maintains a view of the datasource so you can
easily
access the current DataView as well as the current DataRowView:

Dim dv As DataView = DirectCast(CM.L ist, DataView)
Dim dvr As DataRowView = DirectCast(CM.C urrent, DataRowView)

You can obtain currency managers for any table/path in your dataset even
if
there are no control bindings set (in that case the Bindings.Count would
be
0). Complex winforms databinding can take some practice, but once you get
the hang of it you can create some very cool forms.

-B

"pmcguire" <pm******@discu ssions.microsof t.com> wrote in message
news:8E******** *************** ***********@mic rosoft.com...
> Can someone explain to me the difference between these two bindings?
>
> dim b as Binding
>
> b=New Binding(dsMyDat aset.tblMyTable , "colMyColum n")
>
> b=New Binding(dsMyDat aset, "tblMyTable.col MyColumn")
>
> They produce different behavior in my application. I know which one I
> must
> use, but I don't understand why.
>
> Thanks for the help.
> --
> Pat


Nov 21 '05 #4
Pat,

The trouble is that with seeing this code I don't know as I earlier asked
what goes wrong and as well not what you want to achieve.

The second is that it is about a strongly typed dataset, what I never use
and therefore for me a little bit extra difficult to understand what goes
wrong.

Therefore tell me first a little bit what you want.

Probably you get no answer more today, I have to go however maybe somebody
else sees it than..

Cor
Nov 21 '05 #5

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

Similar topics

3
3170
by: Kevin Swanson | last post by:
I'm writing what should be a very simple app against an Oracle database. The app has a number of user controls, any one of which is loaded into a main display page using the loadControl method, depending on which menu item a user selects. Each of these controls follows the same basic pattern: Get a dataset from the database and then display the results using basic databinding. Everything works fine except that I'll occaisionally get an...
3
1872
by: John Bailey | last post by:
When I first built a few web pages in ASP .Net 2.0, I thought it was great. The formview and detailview contorls would automatically layout the controls for you, the update methods were automatically generated, and the objectdatasource let you design against a business object through the gui. Now I am working on my first real web application on 2.0, and I find this automatic functionality doesn't do much beyond allowing me to generate...
4
1664
by: Nathan Sokalski | last post by:
I have two databinding expressions (the first & last names from a DB) that I want to assign to the text property of a Label so that the result is LASTNAME,FIRSTNAME. At the moment, I have the following which I know works when I use it by itself: text='<%# DataBinder.Eval(Container,"DataItem.membernames.lname") %>' What I need to do is somehow concatenate this databinding expression, a comma, and another databinding expression for the...
9
2121
by: Dennis | last post by:
I have tried using Databinding for my application but always seem to find it very restrictive (maybe I don't completely understand it enough). I always seem to find it much easier to display a form, have the user fill it out then put the data into a class representing a data row and then use the OLEadaptor or OLECommands to update the database. My question is has anyone really used databinding in anything but the simpliest application...
8
2196
by: GaryDean | last post by:
We have been noticing that questions on vs.2005/2.0 don't appear to get much in answers so I'm reposting some questions posted by some of the programmers here in our organization that never got answered... In 1.1 we always did our own myDataAdapter.fills and we liked that control for lots of good reasons. Now the new DataSource (or is it a TableAdapter:Dataset) automatically fills the Gridview. How can we control that fill? In a...
0
1333
by: Wayne Sepega | last post by:
I have the following Object DataSource <asp:ObjectDataSource ID="ObjectDataSource1" runat="server" SelectMethod="GetCustomer" TypeName="Customers" DataObjectTypeName="Customer" InsertMethod="InsertCustomer" OnUpdated="ObjectDataSource1_Updated" UpdateMethod="UpdateCustomer" OnSelected="ObjectDataSource1_Selected">
9
24834
by: J055 | last post by:
Hi I have a very simple configuration of the GridView with paging and sorting. When I do a postback the DataBinding event fires twice - in both the ProcessPostData and PreRender stages of the page life cycle. In this example the event fires twice when a) GridView EnableViewState=False and any image type control in the <columns/> element. When either EnableViewState is set to true or the image button is removed, the event fires once....
1
14320
by: CorporateCoder | last post by:
Hi, I am trying to bind the selected value of a databound dropdown box in a databound gridview control to the value being displayed in the template column the dropdown box has been added to. Both the grid and the dropdown box are retrieving and displaying data fine, I just cant bind the two together. I followed the instructions in the help document called 'Walkthrough: Displaying a Drop-Down List While Editing in the GridView Web...
8
2099
by: Dirk | last post by:
Hello, I have a problem to use databinding with my business layer classes. My data class does not have simple properties (string, int or datetime), instead, all my properties are objects of the generic type Field<T> (see sample code). public class Employee { public Field<stringForename
1
1637
by: =?Utf-8?B?QWxoYW1icmEgRWlkb3MgS2lxdWVuZXQ=?= | last post by:
Hello to all, I want to know if DataBinding in asp.net 2,0 is better than to fill up the values of the controls of the following form: this.miControlTextBox.Text = valorParaControlTextbox; Performance with databinding is good in asp.net 2.0 ? Would you prefer: databinding or set value to Text property of control ?
0
11259
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10948
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10483
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9661
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
8035
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5880
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
6076
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4706
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3305
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.