PC Review


Reply
Thread Tools Rate Thread

DataBinding - null values if controll not touched

 
 
Adam Klobukowski
Guest
Posts: n/a
 
      13th Apr 2005
Hello

I'm binding untyped DataSet field to checkbox "Checked" property.
(dataset is filled with data from MSSQL database, DB_FIELD can not be NULL)

Here is the code snippet:

b = new Binding("Checked", this.dataSet.Tables[0], DB_FIELD");

b.Format += new ConvertEventHandler(dbnull2null_checked);
b.Parse += new ConvertEventHandler(dbnull2null_checked);
this.myCheckbof.DataBindings.Add(b);

and dbnull2null_checked is following:

protected void dbnull2null_checked(object sender, ConvertEventArgs cevent)
{
if (cevent.Value.Equals(DBNull.Value)) cevent.Value = false;
if (cevent.Value == null) cevent.Value = 0;
}

Unfortunetly, if the user did not changed value of the checkbox,
database gets null (and throws an exception). If value is changed (to
whatever value) everything is fine.

How to fix it? I'm desperate

--
Semper Fidelis

Adam Klobukowski
(E-Mail Removed)
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
WinForms Databinding and NULL values Jack Tripper Microsoft Dot NET Framework Forms 0 13th May 2010 04:57 PM
Multiple Table values visible in controll box Gary Microsoft Access Forms 2 3rd Feb 2009 10:55 PM
Databinding ComboBox with NULL values =?Utf-8?B?RGF2aWQgTWNDbGVsbGFuZA==?= Microsoft Dot NET Framework Forms 0 2nd Feb 2006 06:32 PM
Databinding Null (VB Nothing) values =?Utf-8?B?RGF2aWQgSmVzc2Vl?= Microsoft Dot NET Framework Forms 1 14th Feb 2005 03:46 PM
Re: Databinding null date values-How to? Tim Wilson Microsoft Dot NET Compact Framework 1 2nd Jun 2004 06:31 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:07 PM.