-
Jan 4th, 2010, 01:01 PM
#1
Thread Starter
Lively Member
Displaying NULL DateTimePicker values
Hey,
So I have a database that has null date values in it. When I call the columns from the database with the null datetime values and display it in the datetimepicker text box using a dataset, theres always values in the datetimepicker text box. It sets everything that was in the database with null values to the current date. This is what i have..
Code:
DateOPStartedRevisionDateTimePicker.Text = ds.Tables(0).Rows(0).Item(13).ToString
I just cant figure out a way to get the datetimepicker text box to display nothing if the values are null in the database.
any help would be great!
thanks!
-
Jan 4th, 2010, 04:44 PM
#2
Addicted Member
Re: Displaying NULL DateTimePicker values
Are you using databinding or you manually are filling the control?
-
Jan 4th, 2010, 05:02 PM
#3
Thread Starter
Lively Member
Re: Displaying NULL DateTimePicker values
-
Jan 4th, 2010, 05:19 PM
#4
Addicted Member
Re: Displaying NULL DateTimePicker values
You must to assign the binding's NullValue property
Binding Constructor (String, Object, String, Boolean, DataSourceUpdateMode, Object)
Initializes a new instance of the Binding class that binds the indicated control property to the specified data member of the specified data source. Optionally enables formatting, propagates values to the data source based on the specified update setting, and sets the property to the specified value when a DBNull is returned from the data source.
Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
Syntax
Visual Basic (Declaration) Public Sub New ( _
propertyName As String, _
dataSource As Object, _
dataMember As String, _
formattingEnabled As Boolean, _
dataSourceUpdateMode As DataSourceUpdateMode, _
nullValue As Object _
)
-
Jan 4th, 2010, 05:24 PM
#5
Thread Starter
Lively Member
Re: Displaying NULL DateTimePicker values
ok so the code you gave me there, i just implement that in my code? and what about my first bit of code up top. is there anything i should do with that?
sorry im still a bit new to this.
-
Jan 5th, 2010, 07:40 AM
#6
Addicted Member
Re: Displaying NULL DateTimePicker values
Dim BndControl as Binding
BndControl=New Binding("Value",MyTable,"MyDateFieldName",False,DataSourceUpdateMode.OnValidation,"My Null Text")
MyDateTimePickerControl.DataBindings.Add(BndControl)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|