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

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

Post by Dylan Beat » Tue, 21 Sep 2004 17:36:27


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.yqcomputer.com/

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

-------------------------------------------------------
Dylan Beattie | ICQ 34865704 | www.dylanbeattie.net
-------------------------------------------------------
 
 
 

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

Post by Dylan Beat » Tue, 21 Sep 2004 18:36:06

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