473,398 Members | 2,113 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

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 3727
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Bruce Duncan | last post by:
I know this should be simple...but for some reason my brain isn't working. I want my users to enter a the date in three seperate boxes. After the users enters in two digits for the month I want...
2
by: Tu Quach | last post by:
Hi there, how are you? I have question, assume I have a text box and gave it a format date&time, how can I check when it is empty or not empty I use the code as if frm_form!txt_name1 = Null...
4
by: merlin | last post by:
greetings to all. i am new to the group and to access. I am using access 97 to setup our clinic's database and in one of the tables I need to be able to type in a date only in terms of the...
2
by: Bradley | last post by:
I want to set the scroll bar and cursor the bottom of a constantly updating textbox. I am under the impression that: txtBox.SelectionStart = txtBox.TextLength should do the trick, but it doesn't...
2
by: David Veeneman | last post by:
What's the simplest way to format a date in a FormView control? I've been looking for something like a DataFormatString property, but it doesn't look like the control itself, nor the consitutent...
1
by: Phillip Vong | last post 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...
2
by: sck10 | last post by:
Hello, I have 3 objects: LinkButton GridView FormView The LinkButton is used to open the FormView in Insert mode. The GridView provides a list of products. When the "Select" link is
7
by: dunkleypilot | last post by:
Hello, I have created a database to track the flights on three aircraft owned by the flight school I manage. The relevant fields in the FlightRecords table are Date, AircraftID, HourMeterOut, and...
7
by: buddyr | last post by:
Hello, txtbox one has a date. txtbox two has a number. number is number of days) txtbox three is empty. I have alot more going on but this is my question: can I add txtbox1 + txtbox2 and show...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.