We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Databind and Datatime textbox control

Thread ID:





94573 May 20,2010 08:38 PM UTC May 26,2010 11:12 AM UTC ASP.NET Web Forms (Classic) 3
Tags: Tools
James Knowlton
Asked On May 20, 2010 08:38 PM UTC

I'm trying to use the DateTime textbox control with data binding. I assume that Value='<%# bind("column_name") %>' should work, and it appears to except in my first test the column returned from the database is NULL. I've set the EnableNullDate and EnableNullKeys = true. I've specified the NULLString = "". I haven't tried the IsNullDate=True yet but that seems out of place, I don't know the date will always be null to begin with. (I'll test that setting in a little bit)

Just wondering if I was missing something obvious?

Appreciate any help,


James Knowlton

Lakxman Kumar C [Syncfusion]
Replied On May 21, 2010 12:51 PM UTC

Hi James,

Thank you for your interest in Syncfusion Products.

Kindly follow the Direct-Trac incident created by you for further updates on this query.

Thank you for your participation in Syncfusion’s Community Forums.

Lakxman Kumar C

James Knowlton
Replied On May 21, 2010 05:47 PM UTC

Sorry about the double posting, I submitted this one prior to the bug report. In the meantime while your development team researches the problem I instituted a workaround and am providing here in the event it might help someone else:

In the aspx page markup I bind the data value ONLY to the Text attribute of the control, then in the code behind I use the Databound event test the text value and set the control's value appropriately. Seems to work so far, though I have not tested updating the database with the controls end value.

Here is the code:

Private Sub dvBiographical__DataBound(ByVal sender As Object, ByVal e As System.EventArgs) Handles dvBiographical_.DataBound
' ========================================================================================
' Name: dvBiographical__DataBound
' Parameters:
' - sender (Object)(ByVal) :
' - e (EventArgs)(ByVal) :
' Returns:
' Author: James.Knowlton
' Desc: This routine handles the databound event for the dvBiographical_ control.
' NOTE: Normally I don't require any specialized code for this event (except when I want to provide custom/specialized formatting)
' I'm using this routine to manually set the "value" attribute of the syncfusion datetimeTextbox control
' which seems to lack proper dbNULL value handling.
' Hopefully this will only be a temporary solution until syncfusion provides an update or other workaround.
' ========================================================================================
' 100521 - JLK - Initial Development
' ========================================================================================

'while unlikely, lets make sure...
If sender Is Nothing Then Return 'take no action

'convert our sender object (I may want this routine to handle multiple DV's in which case I can use a generic variable name)
Dim loDetailView_ As DetailsView = CType(sender, DetailsView)

'The Syncfusion controls are only present in the Edit Templates, so unless we are in edit mode we don't need to take any action
If loDetailView_.CurrentMode = DetailsViewMode.Edit Then
'Get a reference to our problem control...
Dim loControl_ As DateTimeTextBox = CType(loDetailView_.FindControl("dttbBirth_Date_"), DateTimeTextBox)
'if the text is empty then the database returned a null value, so handle appropriately
If loControl_.Text Is Nothing OrElse loControl_.Text = String.Empty Then
loControl_.IsNullDate = True 'tells the control it's dealing with a null (probably means I'll get a dbnull.value back when I send it back to the DB (I hope!)
'convert string to date and set the value
' NOTE: I doubt we could have anything other than a real date, but better safe than sorry.
If IsDate(loControl_.Text) Then
loControl_.Value = CType(loControl_.Text, DateTime)
loControl_.IsNullDate = False
loControl_.Text = ""
loControl_.IsNullDate = True
End If
End If

End If 'loDetailView_.CurrentMode = DetailsViewMode.Edit

End Sub 'dvBiographical__DataBound

Lakxman Kumar C [Syncfusion]
Replied On May 26, 2010 11:12 AM UTC

Hi James,

Thank you for the workaround. Hope this will be usefull for someone who is in need of this untill the fix is available in our build.

Thank you for your participation in Syncfusion’s Community Forums.

Lakxman Kumar C


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

or the page will be automatically redirected to sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon