bind null value to date time picker

  • hi all

     

    Q1) I am using vb.net 2002 and sql server for my project.

    When I bind the NULL value (SQL Server, datatype = datetime) to a date time picker vb.net....it return me an error

    Q2) How to make the date time picker in vb.net which allow is to insert a blank value????

    Can anyone help me to solve this problem

  • re. Q1) Have you thought about using the sqlDateTime data type which supports nulls? using System.Data.SqlTypes;

    Not quite sure I understand the second question..perhaps you could expand a bit.

    Cheers

    Andy

  • Hi andy

    for question 2, i mean the value in the date time picker always shown in the text box, it not allow me to delete the date or make it blank. For my case i need the date become blank. please help

    thanks for reply....

    loon

  • I guess you need to create your own version of the datepicker that inherits the datetime picker and allow it to have a null value. Not sure how you go about this...have not really had much time to play with dot net. I think the general idea of the datetimepicker control is to insist on getting a date out of it which is why it does not allow null. You could just use a text box and have date validator controls. Must rush...should really be working!

    Cheers

    Andy

    Also loon

  • The datetimepicker exhibits a similar problem from vb6; when there is no date, I wanted it to be blank...i think it defaults to current date.

     

    In vb6, this trick will hide the date:

    dtcompldt.Checkbox = True

            If IsNull(dtcompldt.value) Then

               dtcompldt.CustomFormat = " "

            Else

               dtcompldt.CustomFormat = "MM-dd-yyyy"

            End If

     

    The same trick might work in .NET

    Hope that helps.

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply