XSD NullValue property not working in databound TextBox controls (WinForms)

D

Dylan Beattie

Hello there.

I'm having problems getting the nullValue property to work correctly on
databound controls, and I could use a little help! Source code is at
http://www.dylanbeattie.net/misc/adonet/

My project is a desktop interface to a SQL Server database, built using
datasets and dataadapters, but I've reduced the problem to this simple
example. I have a column called "Mobile" in my table, which contains only
null values. I've generated a DataSet from this table, and set the NullValue
property to "NULL_FIELD" for this column. This appears to have worked - when
I view the XML, the appropriate msprop:nullValue="NULL_FIELD" attribute has
been added; also, the null value is appearing in the code-behind class (when
I do a "show all files" and open the DataSet1.cs file, it includes blocks
like:

public string Mobile {
get {
if (this.IsMobileNull()) {
return "NULL_FIELD";
} else {
return ((string)(this[this.tableAccount.MobileColumn]));
}
}
set {
this[this.tableAccount.MobileColumn] = value;
}
}

I have a TextBox on my form bound to the Mobile column of my dataset. This
TextBox always displays an empty string - it never shows the "NULL_FIELD"
value I've specified.

If I set a breakpoint in the get() accessor above, it is never reached
(although breakpoints in the InitClass() method of my DataSet class are
working properly.) - which makes me think the databinding is bypassing these
get/set properties and binding directly to the underlying values.

I haven't had any luck searching MSDN or Google... has anyone else seen this
problem? Am I just missing something obvious?

Thanks in advance,

Dylan
 
D

Dylan Beattie

Apologies for the repost, folks - I've just found out about the MSDN
subscribers managed newsgroup address thingy. I also forgot to add version
information; this is in Visual Studio .NET 2003:

Microsoft Visual C# .NET 69462-335-0000007-18221
Microsoft Visual Studio .NET 2003 Hotfix (KB841870)

Thanks again,

Dylan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top