By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,837 Members | 1,195 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,837 IT Pros & Developers. It's quick & easy.

Display Todays Date in DetailView Template Field while Inserting ?

P: n/a
Hi,

Any Idea how to Display Todays Date in DetailView Template Field while Inserting ?

For example: When I click on New Button of DetailView Control, I need to display Today's Date in a Template Field text box.

I tried following in DetailView1_ModeChanged Event but could not succeed.

Protected Sub DetailsView1_ModeChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DetailsView1.ModeChanged

Dim oText As TextBox = CType(Me.DetailsView1.Rows(0).FindControl("txtmyDa te"), TextBox)

oText.Text = Date.Today.ToShortDateString
EndSub

Best Regards,

Luqman


Apr 6 '07 #1
Share this Question
Share on Google+
2 Replies


P: n/a
On Apr 6, 3:57 pm, "Luqman" <pearls...@cyber.net.pkwrote:
Hi,

Any Idea how to Display Todays Date in DetailView Template Field while Inserting ?

For example: When I click on New Button of DetailView Control, I need to display Today's Date in a Template Field text box.

I tried following in DetailView1_ModeChanged Event but could not succeed.

Protected Sub DetailsView1_ModeChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DetailsView1.ModeChanged

Dim oText As TextBox = CType(Me.DetailsView1.Rows(0).FindControl("txtmyDa te"), TextBox)

oText.Text = Date.Today.ToShortDateString

EndSub

Best Regards,

Luqman
Try this

in the txtMyDate.OnDataBound event set the Text property to the date

Apr 7 '07 #2

P: n/a
Hi,

I tried following and it worked out, thanks a lot.

Protected Sub DetailsView1_DataBound(ByVal sender As Object, ByVal e As
System.EventArgs) Handles DetailsView1.DataBound

If DetailsView1.CurrentMode = DetailsViewMode.Insert Then

Dim oText As TextBox = CType(Me.DetailsView1.FindControl("txtmyDate"),
TextBox)

oText.Text = Date.Today.ToShortDateString

End If

End Sub

Best Regards,

Luqman



"wmain" <ma*********@gmail.comwrote in message
news:11**********************@n76g2000hsh.googlegr oups.com...
On Apr 6, 3:57 pm, "Luqman" <pearls...@cyber.net.pkwrote:
>Hi,

Any Idea how to Display Todays Date in DetailView Template Field while
Inserting ?

For example: When I click on New Button of DetailView Control, I need to
display Today's Date in a Template Field text box.

I tried following in DetailView1_ModeChanged Event but could not succeed.

Protected Sub DetailsView1_ModeChanged(ByVal sender As Object, ByVal e As
System.EventArgs) Handles DetailsView1.ModeChanged

Dim oText As TextBox =
CType(Me.DetailsView1.Rows(0).FindControl("txtmyD ate"), TextBox)

oText.Text = Date.Today.ToShortDateString

EndSub

Best Regards,

Luqman

Try this

in the txtMyDate.OnDataBound event set the Text property to the date

Apr 9 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.