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

problems with parsing & format in ConvertEventArgs when field value is DBNULL (without HTML formating)

Neo
I have a table Contacts with a field "Male" which is of type Bit (SQL
Server).

I've got two radio buttons in a panel, & one of them is bound to the above
field, (so that one can see if the contact is a Male of FeMale - determine
or change the gender).
Below is the coding.

BUT, if i have a record where the Male field is "NULL", then all hell breaks
lose, & i get the below error

An unhandled exception of type 'System.InvalidCastException' occurred in
system.windows.forms.dll
Additional information: Object cannot be cast from DBNull to other types.

Any solutions??? (i'm totally lost)

Code ->

Dim dbnGender As New Binding("Checked", poDataTable, "Male")
AddHandler dbnGender.Format, AddressOf MaleToBollean
AddHandler dbnGender.Parse, AddressOf BooleanToMale
rdoMale.DataBindings.Add(dbnGender)

Protected Sub MaleToBollean(ByVal sender As Object, ByVal e As
ConvertEventArgs)
Try
e.Value = e.Value
Catch exp As Exception
MessageBox.Show("Data entry error: " & exp.Message, Me.Text,
MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End Sub
Protected Sub BooleanToMale(ByVal sender As Object, ByVal e As
ConvertEventArgs)
Try
e.Value = IIf(e.Value, 1, 0)
Catch exp As Exception
MessageBox.Show("Data entry error: " & exp.Message, Me.Text,
MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End Sub
Nov 21 '05 #1
0 874

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

Similar topics

0
by: Dr. Paul Caesar - CoullByte (UK) Limited | last post by:
Hi all! I have a windows form that is bound to a dataset. Using VS 2005 & .NET Framework Beta 2. In my dataset I have a colum called Warranty that is a smallint on SQL Server 2000(SP4). ...
3
by: Slonocode | last post by:
I have some textboxes bound to an access db. I wanted to format the textboxes that displayed currency and date info so I did the following: Dim WithEvents oBidAmt As Binding oBidAmt = New...
1
by: Rich | last post by:
Hello, I have some datefields in a dataset (ds1). I bind some textbox controls on a windows form to these date fields in ds1, but I only want to see 01/01/2004 instead of 1/1/2004 8:00:00 AM. ...
1
by: Agnes | last post by:
In my tables, there are invoicedate, as i use databinding, bind the invoicedate to the textbox, It show mm-dd-yyyy time. I need to change it into date dd-mm-yyyy only without time . how can i do...
13
by: Agnes | last post by:
I know someone post the solution before, but I didn't keep in mind . So I am sorry to ask the same question again I had bind a datatime to the textbox name txtInvoice I want it displayed in...
1
by: Neo | last post by:
I have a table Contacts with a field "Male" which is of type Bit (SQL Server). I've got two radio buttons in a panel, & one of them is bound to the above field, (so that one can see if the contact...
2
by: Neo | last post by:
I have a table Contacts with a field "Male" which is of type Bit (SQL Server). I've got two radio buttons in a panel, & one of them is bound to the above field, (so that one can see if the...
5
by: Carrie | last post by:
Good Morning, I have a combobox whose list is bound to DataSet1.Sales Growth Options.Sales Growth. The data is double and I would like it displayed as a percentage. I have tried two things: ...
2
by: Cerebral Believer | last post by:
Hi folks, Can anyone help me with this form: http://futurebydesign-music.com/_member/club_fbd_reg.php I have followed to coding instructions aas closely as I can, but I am getting errors...
7
by: pamela fluente | last post by:
My numericUpDowns show numbers in the format 1.500,56 (italy). Instead, I need *invariantly* that they show and accept the format 1,500.56, as in the USA. What's the right way to do that? I...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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.