473,395 Members | 1,702 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

custom control with multiple data binds

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

Jul 6 '06 #1
6 1130
"codoherty" <co*******@discussions.microsoft.coma écrit dans le message de
news: 60**********************************@microsoft.com...

| 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
Jul 7 '06 #2
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" <co*******@discussions.microsoft.coma écrit dans le message de
news: 60**********************************@microsoft.com...

| 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
Jul 7 '06 #3
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" <co*******@discussions.microsoft.coma écrit dans le message de
news: 60**********************************@microsoft.com...

| 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
Jul 7 '06 #4
"codoherty" <co*******@discussions.microsoft.coma écrit dans le message de
news: FF**********************************@microsoft.com...

| 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
Jul 7 '06 #5
Hi Joanna,

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

Many Thanks
"Joanna Carter [TeamB]" wrote:
"codoherty" <co*******@discussions.microsoft.coma écrit dans le message de
news: FF**********************************@microsoft.com...

| 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
Jul 7 '06 #6
"codoherty" <co*******@discussions.microsoft.coma écrit dans le message de
news: 27**********************************@microsoft.com...

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

You're welcome.

Joanna

--
Joanna Carter [TeamB]
Consultant Software Engineer
Jul 7 '06 #7

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

Similar topics

0
by: Dan | last post by:
i have a custom control. In the page load of the control I call a procedure called binddata which gets a dataset and binds to a gird. Then in my webform I create and instance of the control and...
21
by: One Handed Man \( OHM - Terry Burns \) | last post by:
When using a custom control. In order to check and see if values have changed one has to implement the IPostBackDataCollection interface. The values returned for the control seem to be simply a...
1
by: Sam Samnah | last post by:
Hi Everyone. It has been a long time since my last post. Nevertheless, I have built a custom server control that allows a user to edit text, bolding, italics strike though table insertion and...
2
by: Mike | last post by:
Hi, I am strugling with a simple problem which I can't seem to resolve. I have an asp.net page which contains a server-control (flytreeview, which is a kind of a tree to be exact). The tree is...
0
by: Iain | last post by:
Can I apologise for the lengthy nature of this post. The scenario is complicated (though I hope the solution is not!) basically, I've got a custom template control which binds itself to a tree...
5
by: Alan Silver | last post by:
Hello, I have a products page that takes a product ID in the query string. Based on the product details (from a database), the page then loads up one of a number of custom controls, calls a...
0
by: jmawebco | last post by:
I would like to know of anyone could tell me if the following is possible; I want to create a user control that will retrieve data from a database and create 4 seperate dropdown lists. The data...
0
by: Proteus | last post by:
Hi, I am trying to extend the ASP.NET 2.0 DropDown List control. I have created a new custom control and inherited from the ASP.NET control. This works fine and I can drag it on to my web page...
14
by: Rolf Welskes | last post by:
Hello, I have an ObjectDataSource which has as business-object a simple array of strings. No problem. I have an own (custom) control to which I give the DataSourceId and in the custom-control...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...

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.