Tuesday, March 13, 2012

Simple Fomatting question. Date to String and back.

I have a simple Formview and in the InsertMode I have a calendar and a
textbox. All I want is for people to click on a date and the date is
populated to the textbox. Here is my simple code and my problem is
converting the DateTxtBox to a date format. Can someone show me how to do
this simple conversion?

Thanks!

Protected Sub Calendar2_SelectionChanged(ByVal sender As Object, ByVal e As
System.EventArgs)

Dim CalDate As Calendar

CalDate = FormView1.FindControl("Calendar2")

Dim test As Date

test = CalDate.SelectedDate

Dim DateTxtBox As TextBox

DateTxtBox = FormView1.FindControl("DateTextBox")

DateTxtBox = test

End SubNever mind, I figured it out.

Protected Sub Calendar2_SelectionChanged(ByVal sender As Object, ByVal e As
System.EventArgs)

Dim CalDate As Calendar

CalDate = FormView1.FindControl("Calendar2")

Dim test As Date

test = CalDate.SelectedDate.ToString

Dim DateTxtBox As TextBox

DateTxtBox = FormView1.FindControl("DateTextBox")

DateTxtBox.Text = test

End Sub

"Phillip Vong" <phillip_vong*at*yahoo*dot*comwrote in message
news:u72t$D39GHA.3256@.TK2MSFTNGP02.phx.gbl...

Quote:

Originally Posted by

>I have a simple Formview and in the InsertMode I have a calendar and a
>textbox. All I want is for people to click on a date and the date is
>populated to the textbox. Here is my simple code and my problem is
>converting the DateTxtBox to a date format. Can someone show me how to do
>this simple conversion?
>
Thanks!
>
>
Protected Sub Calendar2_SelectionChanged(ByVal sender As Object, ByVal e
As System.EventArgs)
>
Dim CalDate As Calendar
>
CalDate = FormView1.FindControl("Calendar2")
>
Dim test As Date
>
test = CalDate.SelectedDate
>
Dim DateTxtBox As TextBox
>
DateTxtBox = FormView1.FindControl("DateTextBox")
>
DateTxtBox = test
>
>
End Sub
>
>

0 comments:

Post a Comment