Display Todays Date in DetailView Template Field while Inserting ?

L

Luqman

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("txtmyDate"), TextBox)

oText.Text = Date.Today.ToShortDateString


EndSub

Best Regards,

Luqman
 
W

wmain

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("txtmyDate"), TextBox)

oText.Text = Date.Today.ToShortDateString

EndSub

Best Regards,

Luqman

Try this

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

Luqman

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top