PC Review


Reply
Thread Tools Rate Thread

Binding same column to multiple properties

 
 
Marina
Guest
Posts: n/a
 
      21st May 2004
Hi,

Let's say I bind the same column to multiple properties of one control (or
even to the same property of several controls).

If a user changes the value of the property in one control - I would like to
take that value, and put it in the data source, and have anything else bound
to this column get updated with the new value.

However, called EndCurrentEdit, resets the value to the original, and
basically throws out the new value.

If however, I updated the value in all the other controls/properties bound
to this column, to the new value just entered - only then does
EndCurrentEdit put the new value into the datasource.

What I need is to have EndCurrentEdit accept the value and put it in the
datasource, so that then I can call Refresh, to have anything else bound to
the column receive the new value. If I have to put the value in myself in
every control bound to the column, that seems to defeat the purpose.

How can this be done?



 
Reply With Quote
 
 
 
 
Cor Ligthert
Guest
Posts: n/a
 
      21st May 2004
Hi Marina,

I am not sure if I understand your question (Because it is you I think it is
not an easy question), however did you already see what using different
dataviews can do for you, that I used with success.

(You should look in the adonet group, Jon (he tested somehing and now) is
completly to the other side (ours) about dispose in my opinion)

Cor


 
Reply With Quote
 
Marina
Guest
Posts: n/a
 
      21st May 2004
Here is the thing:

If I have 2 controls, each with a textbox. I bind the same column to each of
the textbox's Text properties. Then everything works as expected.

However, if one of the properties is another property (say a custom
property), then suddenly calling EndCurrentEdit does not work.

This is a very dynamic form, and I do not know which control with which
property will get bound to what. Because of that, i would need a separate
dataview for each binding - which has got to be expensive.

It seems to come down to the name of the property. As long as both
properties are the Text property, then it's all fine. If one of the
properties is a custom property I wrote, then changing the value of the
column in the Text property and calling EndCurrentEdit, discards the
changes, instead of sending them back to the datasource.

"Cor Ligthert" <(E-Mail Removed)> wrote in message
news:Oo$(E-Mail Removed)...
> Hi Marina,
>
> I am not sure if I understand your question (Because it is you I think it

is
> not an easy question), however did you already see what using different
> dataviews can do for you, that I used with success.
>
> (You should look in the adonet group, Jon (he tested somehing and now) is
> completly to the other side (ours) about dispose in my opinion)
>
> Cor
>
>



 
Reply With Quote
 
Cor Ligthert
Guest
Posts: n/a
 
      21st May 2004
Hi Marina,

I think there is to much to gues in it for me, did you ever see that strange
behaviour of binding the text property from a combobox, your problem sounds
the same for me.

I never succeeded in getting a real answer on that, that did solve or
workaround the problem.

Cor


 
Reply With Quote
 
Marina
Guest
Posts: n/a
 
      21st May 2004
No, sorry, this is really completely different. When you are talking about a
combox, you are talking about changing the position of the current row -
this isn't what i am doing at all, this is all on the same row.

"Cor Ligthert" <(E-Mail Removed)> wrote in message
news:ebd%(E-Mail Removed)...
> Hi Marina,
>
> I think there is to much to gues in it for me, did you ever see that

strange
> behaviour of binding the text property from a combobox, your problem

sounds
> the same for me.
>
> I never succeeded in getting a real answer on that, that did solve or
> workaround the problem.
>
> Cor
>
>



 
Reply With Quote
 
Cor Ligthert
Guest
Posts: n/a
 
      21st May 2004
Hi Marina,

This does work in my opinion fine.
(I places some buttons in your code to test it)

Cor

\\\
Dim dt As New DataTable
Dim dv1 As DataView
Dim dv2 As DataView
Private Sub Form2_Load(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
dt.Columns.Add("MyColumn")
Dim row As DataRow = dt.NewRow
row(0) = "TestValue"
dt.Rows.Add(row)
dv1 = New DataView(dt)
dv2 = New DataView(dt)
MyTextBox1.DataBindings.Add("Text", dv1, "MyColumn")
MyTextBox1.DataBindings.Add("MyProperty", dv2, "MyColumn")
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click
MyTextBox1.Text = "TextValue"
Me.BindingContext(dv1).EndCurrentEdit()
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button2.Click
MyTextBox1.MyProperty = "PropValue"
Me.BindingContext(dv2).EndCurrentEdit()
End Sub
////


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Binding multi column values in one column Larry R Microsoft ASP .NET 1 8th Jun 2007 07:27 AM
GridView / Binding Sub Properties =?Utf-8?B?RGVtZXRyaQ==?= Microsoft ASP .NET 0 3rd Jul 2006 02:50 PM
Two-way binding is only supported for properties ME Microsoft ASP .NET 0 21st Feb 2006 12:34 AM
Problem binding multiple properties in one control to a single row =?Utf-8?B?amNwb2lyaWVy?= Microsoft ADO .NET 0 14th Jan 2005 07:17 PM
Advice for binding properties of multiple objects Lance Microsoft VB .NET 3 2nd Dec 2003 08:45 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:55 AM.