Data Binding using an expression in datafld 
Author Message
 Data Binding using an expression in datafld

If you are using VB as your front-end, then you can use the
BindingCollection and StdDataFormat objects to format data that is bound to
an ActiveX control.  If you are using ASP / HTML controls, then this will
not work.

Dim m_oBindingCollection As BindingCollection
Dim WithEvents m_sdfLastEditDate As StdDataFormat


' Create a new instance
Set m_oBindingCollection = New BindingCollection
Set m_sdfLastEditDate = New StdDataFormat


'  Use the BindingCollection object to bind txtLastEditedDate to m_oRDC
using the Standard Data Format object
Set m_oBindingCollection.DataSource = m_oRDC
m_oBindingCollection.Add txtLastEditedDate, "Text", "LastEditedDateTime",


' Occurs after the StdDataFormat object formats the value.
Private Sub m_sdfLastEditDate_Format(ByVal DataValue As
    DataValue = Format(DataValue, "Short Date")
End Sub

' Occurs after the StdDataFormat object unformats the value.
Private Sub m_sdfLastEditDate_UnFormat(ByVal DataValue As
    DataValue = Format(DataValue, "yyyy-mm-dd hh:mm:ss")
End Sub



Carl Prothman
Microsoft Visual Basic MVP,
Certified Computer Professional (CCP)

> Is it possible to use an expression such as Day(FromDate) in the datafld
> property of a bound column on a text box?

> Mal Ball

Sun, 14 Jul 2002 03:00:00 GMT  
 [ 1 post ] 

 Relevant Pages 

1. Using datafld expression?

2. Data-bound Masked Edit makes all data-bound controls not display data

3. Assigning Null Values to data bound fields using remote data control

4. Data Bound Combo Box within a Data Bound Grid

5. Data bound Combos or Not Data Bound Combos

6. Data-Bound Vs. Non-Data-Bound Controls

7. Data-Bound Vs. Non-Data-Bound Controls

8. Data-Bound Vs. Non-Data-Bound Controls

9. Field Names and Data Types used in expressions.

10. Using Regular Expression against Unicode data

11. Problem with Updating Dataset contents back to db when using data binding

12. Saving/Adding a record using data bound text fields


Powered by phpBB® Forum Software