Results 1 to 6 of 6

Thread: Displaying NULL DateTimePicker values

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Nov 2009
    Location
    Toronto
    Posts
    103

    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!

  2. #2
    Addicted Member Cristian's Avatar
    Join Date
    Jun 2006
    Posts
    228

    Re: Displaying NULL DateTimePicker values

    Are you using databinding or you manually are filling the control?

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Nov 2009
    Location
    Toronto
    Posts
    103

    Re: Displaying NULL DateTimePicker values

    I am data binding

  4. #4
    Addicted Member Cristian's Avatar
    Join Date
    Jun 2006
    Posts
    228

    Wink 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 _
    )

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Nov 2009
    Location
    Toronto
    Posts
    103

    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.

  6. #6
    Addicted Member Cristian's Avatar
    Join Date
    Jun 2006
    Posts
    228

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



Click Here to Expand Forum to Full Width