DateTimeControl in Sharepoint


Hi,
I would like to discuss about an issue I faced when I was developing for my project. This could help some who also faced the same issue as mine.
I am not too good in writing articles so please bear with me if I am not up to your expectations…:)

I had datetimecontrol in my webpart with Dateonly option as true. But when I leave the field blank and save the rest of the data to the webpart I got a default value stored in the list I was storing the information to.

I used the following method to solve this. Thanks to Yogesh Sharma who helped me in this.

if (txtStartDate.IsDateEmpty) {
lstItem[“StartDate”] = null;
} else {
lstItem[“StartDate”] = txtStartDate.SelectedDate.ToShortDateString();
}

This added the value for date only if I selected a value from the calendar. This may look simple to many but if it helps even one I will be happy

Advertisements

About gai3kannan

I am working with NCS Pte Ltd as a Lead Consultant I have taken SharePoint as my full time action and thoughts.
This entry was posted in My Own Posts and tagged . Bookmark the permalink.

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s