PC Review


Reply
Thread Tools Rate Thread

custom control with multiple data binds

 
 
=?Utf-8?B?Y29kb2hlcnR5?=
Guest
Posts: n/a
 
      7th Jul 2006
Is it possible to for a custom control to have 2 properties bound to 2
different fields from the same ADO.NET datasource. I noticed when writing
updates to my datasource only 1 field or property from the control is written.

For example....

Custom control:

public class MyControl : Usercontrol
{
[Bindable(true)]
public String PropA
{ get { return valueA; } }

[Bindable(true)]
public String PropB
{ get { return valueB; } }
}

Form Code

this.customControl.DataBindings.Add(new System.Windows.Forms.Binding
("PropA", datasource, "FieldA", true));
this.customControl.DataBindings.Add(new
System.Windows.Forms.Binding("PropB", datasource, "FieldB", true));


Regards

 
Reply With Quote
 
 
 
 
Joanna Carter [TeamB]
Guest
Posts: n/a
 
      7th Jul 2006
"codoherty" <(E-Mail Removed)> a écrit dans le message de
news: 6047E59C-467A-4F22-939F-(E-Mail Removed)...

| Is it possible to for a custom control to have 2 properties bound to 2
| different fields from the same ADO.NET datasource. I noticed when writing
| updates to my datasource only 1 field or property from the control is
written.

Any control can be bound to more than one field on the same object, simply
add one Binding for each property on the control to the respective field.

Joanna

--
Joanna Carter [TeamB]
Consultant Software Engineer


 
Reply With Quote
 
=?Utf-8?B?Y29kb2hlcnR5?=
Guest
Posts: n/a
 
      7th Jul 2006
Hi Joanna,

This is what I thought, but what I have noticed is during the datasource
update, if I update more than 1 field then only the first field is saved.
This is strange because the read operation loads all the fields in the
control properties.

To explain, I have created an address control (street, town, zip, country,
etc...) that I use in many places, I then want to bind the respective fields
to a customer, supplier, bank record etc...

The only problen is, I edit the full address and when writing the record
only the 1 altered field is written to the record? This to me seems strange,
or am I missing something?

Regards

"Joanna Carter [TeamB]" wrote:

> "codoherty" <(E-Mail Removed)> a écrit dans le message de
> news: 6047E59C-467A-4F22-939F-(E-Mail Removed)...
>
> | Is it possible to for a custom control to have 2 properties bound to 2
> | different fields from the same ADO.NET datasource. I noticed when writing
> | updates to my datasource only 1 field or property from the control is
> written.
>
> Any control can be bound to more than one field on the same object, simply
> add one Binding for each property on the control to the respective field.
>
> Joanna
>
> --
> Joanna Carter [TeamB]
> Consultant Software Engineer
>
>
>

 
Reply With Quote
 
=?Utf-8?B?Y29kb2hlcnR5?=
Guest
Posts: n/a
 
      7th Jul 2006
Ok! It seems that you have to exit (lose focus) the custom control after each
field edit. Is there any way to combat this behaviour.

"Joanna Carter [TeamB]" wrote:

> "codoherty" <(E-Mail Removed)> a écrit dans le message de
> news: 6047E59C-467A-4F22-939F-(E-Mail Removed)...
>
> | Is it possible to for a custom control to have 2 properties bound to 2
> | different fields from the same ADO.NET datasource. I noticed when writing
> | updates to my datasource only 1 field or property from the control is
> written.
>
> Any control can be bound to more than one field on the same object, simply
> add one Binding for each property on the control to the respective field.
>
> Joanna
>
> --
> Joanna Carter [TeamB]
> Consultant Software Engineer
>
>
>

 
Reply With Quote
 
Joanna Carter [TeamB]
Guest
Posts: n/a
 
      7th Jul 2006
"codoherty" <(E-Mail Removed)> a écrit dans le message de
news: FF127895-D5EA-4015-9E42-(E-Mail Removed)...

| Ok! It seems that you have to exit (lose focus) the custom control after
each
| field edit. Is there any way to combat this behaviour.

Well, I assume you are using more than one control to enter the values ?

If so, you need to connect the different bindings, one to each
"sub-control", to the relevant property.

Does this make any sense to you ? :-)

Joanna

--
Joanna Carter [TeamB]
Consultant Software Engineer


 
Reply With Quote
 
=?Utf-8?B?Y29kb2hlcnR5?=
Guest
Posts: n/a
 
      7th Jul 2006
Hi Joanna,

I just figured this, and ya it works, and also makes sense.

Many Thanks


"Joanna Carter [TeamB]" wrote:

> "codoherty" <(E-Mail Removed)> a écrit dans le message de
> news: FF127895-D5EA-4015-9E42-(E-Mail Removed)...
>
> | Ok! It seems that you have to exit (lose focus) the custom control after
> each
> | field edit. Is there any way to combat this behaviour.
>
> Well, I assume you are using more than one control to enter the values ?
>
> If so, you need to connect the different bindings, one to each
> "sub-control", to the relevant property.
>
> Does this make any sense to you ? :-)
>
> Joanna
>
> --
> Joanna Carter [TeamB]
> Consultant Software Engineer
>
>
>

 
Reply With Quote
 
Joanna Carter [TeamB]
Guest
Posts: n/a
 
      7th Jul 2006
"codoherty" <(E-Mail Removed)> a écrit dans le message de
news: 272909C3-9B6A-4F51-9510-(E-Mail Removed)...

| I just figured this, and ya it works, and also makes sense.
|
| Many Thanks

You're welcome.

Joanna

--
Joanna Carter [TeamB]
Consultant Software Engineer


 
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
Grid/spreadsheet control that binds to a System.Data.Dataset (multi-Datatable)and automagically creates multiple sheets TR Microsoft Dot NET Framework Forms 1 20th Dec 2007 10:10 PM
There is no HTML control which binds correctly to this column typ. =?Utf-8?B?Q2hyaXM=?= Microsoft Access Database Table Design 0 2nd Mar 2005 09:47 AM
RE : Active Directory multiple simultaneous binds on same ldap connection Pradnyesh Rane Microsoft Windows 2000 Active Directory 0 15th Jan 2005 01:50 AM
Active Directory multiple simultaneous binds on same ldap connection Pradnyesh Rane Microsoft Windows 2000 Active Directory 4 15th Jan 2005 12:31 AM
filtering records a control binds to MattB Microsoft ASP .NET 3 2nd Sep 2004 10:20 PM


Features
 

Advertising
 

Newsgroups
 


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