Avatar of Danik_S
Danik_S

asked on 

Calendar control throws error when NULL value is databound to selected date.

Hi

I have a calendar control (calDateGiven) in the editItemTemplate of a gridview which has its visible and selected date properties bound.  Each record may or may not have had a date entered previously.  If a date has not previously been selected then the DateGiven field in the database will contain NULL.  

When the data is bound to the calendar control it throws an error if the database value is NULL because it can't be converted to a date for binding the selected and visible date properties of the calendar.  Fair enough.  So I figured that I need to use the databinding event of the calendar control to check if the recordset value that's about to be bound to the control is NULL and if it is, avoid binding the calendar's propreties.  How do I do this?  Specifically, how do I access the DateGiven value that is about to be bound to the control?

Any help much appreciated.

Cheers,
Danik
.NET ProgrammingVisual Basic.NETASP.NET

Avatar of undefined
Last Comment
Danik_S
Avatar of Decadre
Decadre

ok, I'm having a little bit of trouble following you, especially since I've never playing with a calendar control. However, would something like this work?

If not <database value> = null then 'May have to use nothing perhaps instead of null
<code>
endif
Avatar of Danik_S
Danik_S

ASKER

Hi Decadre

What I want to know is, within the context of the calDateGiven_databinding function,  how do I get <database value>?  In other words, how do I get the value that is about to be bound to the calendar control's properties?

Cheers,
Danik
ASKER CERTIFIED SOLUTION
Avatar of Rajul Patel
Rajul Patel
Flag of India image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of Danik_S
Danik_S

ASKER

Awesome Rajul!  That does exactly what I need!  Thanks a lot.

Danik

.NET Programming
.NET Programming

The .NET Framework is not specific to any one programming language; rather, it includes a library of functions that allows developers to rapidly build applications. Several supported languages include C#, VB.NET, C++ or ASP.NET.

137K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo