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
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