Display Todays Date in DetailView Template Field while Inserting ?

  • Thread starter Thread starter Luqman
  • Start date Start date
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
 
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
 
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
 
Back
Top