473,385 Members | 1,888 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,385 software developers and data experts.

Can I bind a control to a dataset.haschanges property?

Hello,

I was wondering if it was possibly to bind a control to a dataset.haschanges
property.

The reason I want to do this is so that a little warning shows up on the
form saying that the record has not been saved.

Thank you heaps for anyones thoughts
John Sheppard
Dec 5 '07 #1
4 1274
Well, not directly. HasChanges is a method not a property so while it seems
pedantic, it is the reason it won't work. If you really needed thsi
functionality, you could create a property that simply wrapped the call to
HasChanges and bind to it instead but it would need to be subclassed. (note,
I have not specifically done this but since you can bind to other
properites, I'm 99.9% sure you'd be fine if you created a property of your
own.)
"John" <no****@nospam.comwrote in message
news:fj*********@news5.newsguy.com...
Hello,

I was wondering if it was possibly to bind a control to a
dataset.haschanges property.

The reason I want to do this is so that a little warning shows up on the
form saying that the record has not been saved.

Thank you heaps for anyones thoughts
John Sheppard

Dec 5 '07 #2
Ooops, I think I forgot to send this

private void Form1_Load(object sender, EventArgs e)

{

AugmentedDataSet ds = new AugmentedDataSet();
ds.Tables.Add(new DataTable("WhateverTable"));

ds.Tables[0].Columns.Add(new DataColumn("MyColumn", typeof(String)));

chkHasChanges.DataBindings.Add("Checked", ds.HasChanged, null);

}

Coupled with my last post, this should do it for you

"John" <no****@nospam.comwrote in message
news:fj*********@news5.newsguy.com...
Hello,

I was wondering if it was possibly to bind a control to a
dataset.haschanges property.

The reason I want to do this is so that a little warning shows up on the
form saying that the record has not been saved.

Thank you heaps for anyones thoughts
John Sheppard

Dec 5 '07 #3
John:

I just went ahead and did it...
For the whole "Untyped" thing, you can just deal with this class like you
would any other dataset and if you created a typed dataset you could do the
same:

namespace WindowsApplication2

{

public class AugmentedDataSet : DataSet

{

private Boolean hasChanged;

public Boolean HasChanged

{

get { return base.HasChanges(); }

set { hasChanged = value; }

}
}

}

Now here's the binding code:

"John" <no****@nospam.comwrote in message
news:fj*********@news5.newsguy.com...
Hello,

I was wondering if it was possibly to bind a control to a
dataset.haschanges property.

The reason I want to do this is so that a little warning shows up on the
form saying that the record has not been saved.

Thank you heaps for anyones thoughts
John Sheppard

Dec 5 '07 #4
Thanks Ryan,

Sorry for the slow response...I shall try this out...looks good...Thank you
so much for spending the time to trial it out for me.

Kind regards
John Sheppard

"W.G. Ryan" <Wi*********@nospam.gmail.comwrote in message
news:eS**************@TK2MSFTNGP03.phx.gbl...
Ooops, I think I forgot to send this

private void Form1_Load(object sender, EventArgs e)

{

AugmentedDataSet ds = new AugmentedDataSet();
ds.Tables.Add(new DataTable("WhateverTable"));

ds.Tables[0].Columns.Add(new DataColumn("MyColumn", typeof(String)));

chkHasChanges.DataBindings.Add("Checked", ds.HasChanged, null);

}

Coupled with my last post, this should do it for you

"John" <no****@nospam.comwrote in message
news:fj*********@news5.newsguy.com...
>Hello,

I was wondering if it was possibly to bind a control to a
dataset.haschanges property.

The reason I want to do this is so that a little warning shows up on the
form saying that the record has not been saved.

Thank you heaps for anyones thoughts
John Sheppard


Dec 10 '07 #5

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

Similar topics

0
by: tonidapogi | last post by:
Hi! I'm having problems in updating my client database using web service. When I merge datasets (1 from the client and 1 from the web service), and try to update the client database by using the...
0
by: IMS.Rushikesh | last post by:
Hi All, I want to serialize an object which contain the DataTable. As DataSet is MarshalByRef object and is serializable. I am using it directly. Even my data is also serialize and save it to...
4
by: Brian Keating | last post by:
wonder if anyone can help me here, i've a framework 1.1 dataset which i serialize in framework 1.1 and deserialize in framework 2.0. This is fine, problem is that i want to modify some of the...
1
by: TJS | last post by:
Is there a way to do this ??
7
by: Jed | last post by:
I have a web service method that returns an array of custom objects marked serializeable with fully described public properties. When I bind the results to a DataGrid I can access the properties...
3
by: Lori Markle via .NET 247 | last post by:
(Type your message here) Hi, I'm having a problem with binding a textbox to a dataset. Cananybody figure out what's going on here? I simply want to update a record. Type in a permit number...
3
by: AH | last post by:
Hi all, I noticed this strange behavior; I created a new control (example inherits from textbox) and add a new property, then I bind this new property to a field in my dataTable in a dataSet....
5
by: Franck | last post by:
how come unchanged always true even if data changed This code come from my saving button: ============================================ DataSet ds1 = new DataSet(); DataSet ds2 = new...
3
by: John Sheppard | last post by:
Hello there, I have the following code; I do this as a work around for a dataset.haschanges method which doesnt appear to work correctly either For Each dt As DataTable In myDs.Tables If Not...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...

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.