469,890 Members | 1,412 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,890 developers. It's quick & easy.

Simple put current date in a txtbox in Formview - Gozirra

Using VS2005 w/ simple aspx in VB.net

I have a simple databound textbox "LastMtgText" in a formview in the Insert
template.

All I want to do is make the default date of today when someone goes to
Insert template so they do not have to put in todays date. Here is my code,
what am I doing wrong? I know how to do this when not using Formview.

'-----This puts in the current date

Dim dtmToday As Date

dtmToday = Now.Date
Dim convDate As String

convDate = CStr(dtmToday)
Dim LastMtgLabel As Label

LastMtgLabel = FormView1.FindControl("LastMtgTextBox")

LastMtgLabel.Text = dtmToday


Gozirra - I thought I understood what you were trying to teach me about
conversion so I thought this would be easy but I can not get this to work.
Can you please build a simple form and try this? This works fine when not
in Formview.
Oct 12 '06 #1
3 3612
I got it. But I have one last problem.

Dim dtmToday As String
dtmToday = Now.Date.ToString("MM/d/yyy")

Dim LastMtgLabel As TextBox
LastMtgLabel = FormView1.FindControl("LastMtgTextBox")
LastMtgLabel.Text = dtmToday
This codes puts in today's date perfectly in my Textbox, but if I try to
change the date to something else like 12/15/1945 and Insert it, it posted
today's date. No matter what I change it to, it will post today's date. Is
there a reason for this? This code was in the PageLoad so why would it do
this?


"Phillip Vong" <phillip_vong*at*yahoo*dot*comwrote in message
news:uR**************@TK2MSFTNGP02.phx.gbl...
Using VS2005 w/ simple aspx in VB.net

I have a simple databound textbox "LastMtgText" in a formview in the
Insert template.

All I want to do is make the default date of today when someone goes to
Insert template so they do not have to put in todays date. Here is my
code, what am I doing wrong? I know how to do this when not using
Formview.

'-----This puts in the current date

Dim dtmToday As Date

dtmToday = Now.Date
Dim convDate As String

convDate = CStr(dtmToday)
Dim LastMtgLabel As Label

LastMtgLabel = FormView1.FindControl("LastMtgTextBox")

LastMtgLabel.Text = dtmToday


Gozirra - I thought I understood what you were trying to teach me about
conversion so I thought this would be easy but I can not get this to work.
Can you please build a simple form and try this? This works fine when not
in Formview.

Oct 12 '06 #2
I had the same problem, thanks for your help.
This one works for me (put in the if Not IsPostBack..... End if).
I can change the date now en it submits correctly to the database.

Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
Dim dtmToday As String
If Not IsPostBack Then
dtmToday = Now.Date.ToString("dd/MM/yy")
Dim LastMtgLabel As TextBox
LastMtgLabel = FormView1.FindControl("datumTextBox")
LastMtgLabel.Text = dtmToday
End If
End Sub
Phillip Vong wrote:
I got it. But I have one last problem.

Dim dtmToday As String
dtmToday = Now.Date.ToString("MM/d/yyy")

Dim LastMtgLabel As TextBox
LastMtgLabel = FormView1.FindControl("LastMtgTextBox")
LastMtgLabel.Text = dtmToday
This codes puts in today's date perfectly in my Textbox, but if I try to
change the date to something else like 12/15/1945 and Insert it, it posted
today's date. No matter what I change it to, it will post today's date. Is
there a reason for this? This code was in the PageLoad so why would it do
this?


"Phillip Vong" <phillip_vong*at*yahoo*dot*comwrote in message
news:uR**************@TK2MSFTNGP02.phx.gbl...
Using VS2005 w/ simple aspx in VB.net

I have a simple databound textbox "LastMtgText" in a formview in the
Insert template.

All I want to do is make the default date of today when someone goes to
Insert template so they do not have to put in todays date. Here is my
code, what am I doing wrong? I know how to do this when not using
Formview.

'-----This puts in the current date

Dim dtmToday As Date

dtmToday = Now.Date
Dim convDate As String

convDate = CStr(dtmToday)
Dim LastMtgLabel As Label

LastMtgLabel = FormView1.FindControl("LastMtgTextBox")

LastMtgLabel.Text = dtmToday


Gozirra - I thought I understood what you were trying to teach me about
conversion so I thought this would be easy but I can not get this to work.
Can you please build a simple form and try this? This works fine when not
in Formview.
Oct 20 '06 #3
That's perfect!

Thanks!

"MrGreen" <re******@hotmail.comwrote in message
news:11********************@i3g2000cwc.googlegroup s.com...
>I had the same problem, thanks for your help.
This one works for me (put in the if Not IsPostBack..... End if).
I can change the date now en it submits correctly to the database.

Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
Dim dtmToday As String
If Not IsPostBack Then
dtmToday = Now.Date.ToString("dd/MM/yy")
Dim LastMtgLabel As TextBox
LastMtgLabel = FormView1.FindControl("datumTextBox")
LastMtgLabel.Text = dtmToday
End If
End Sub
Phillip Vong wrote:
>I got it. But I have one last problem.

Dim dtmToday As String
dtmToday = Now.Date.ToString("MM/d/yyy")

Dim LastMtgLabel As TextBox
LastMtgLabel = FormView1.FindControl("LastMtgTextBox")
LastMtgLabel.Text = dtmToday
This codes puts in today's date perfectly in my Textbox, but if I try to
change the date to something else like 12/15/1945 and Insert it, it
posted
today's date. No matter what I change it to, it will post today's date.
Is
there a reason for this? This code was in the PageLoad so why would it do
this?


"Phillip Vong" <phillip_vong*at*yahoo*dot*comwrote in message
news:uR**************@TK2MSFTNGP02.phx.gbl...
Using VS2005 w/ simple aspx in VB.net

I have a simple databound textbox "LastMtgText" in a formview in the
Insert template.

All I want to do is make the default date of today when someone goes to
Insert template so they do not have to put in todays date. Here is my
code, what am I doing wrong? I know how to do this when not using
Formview.

'-----This puts in the current date

Dim dtmToday As Date

dtmToday = Now.Date
Dim convDate As String

convDate = CStr(dtmToday)
Dim LastMtgLabel As Label

LastMtgLabel = FormView1.FindControl("LastMtgTextBox")

LastMtgLabel.Text = dtmToday


Gozirra - I thought I understood what you were trying to teach me about
conversion so I thought this would be easy but I can not get this to
work.
Can you please build a simple form and try this? This works fine when
not
in Formview.

Oct 20 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

7 posts views Thread by Bruce Duncan | last post: by
2 posts views Thread by Tu Quach | last post: by
4 posts views Thread by merlin | last post: by
2 posts views Thread by Bradley | last post: by
2 posts views Thread by David Veeneman | last post: by
1 post views Thread by Phillip Vong | last post: by
2 posts views Thread by sck10 | last post: by
reply views Thread by Salome Sato | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.