itemtemplate

Last post 05-12-2007 7:38 PM by ReyN. 2 replies.

Sort Posts:

  • itemtemplate

    05-12-2007, 3:36 PM
    • Loading...
    • NetHero77
    • Joined on 05-12-2007, 1:52 PM
    • Posts 5
    Got a form view setup.  Each item in the InsertTemplate is bond to a field in the table. My problem is how to pre-populate the textbox.  For example, I have a textbox for Date value and I want that populated whenever user comes to that page and then when user click on save the Date value will be written to the database.
  • Re: itemtemplate

    05-12-2007, 7:19 PM
    Answer

    What value do you want to pre-populate it with? Today's date?  What format?  Will the user be able to change this date?

    If the date value will always be the current date, then don't provide a textbox.  Just insert GetDate() if you are using SQL Server, or Date() for Access. 

    Otherwise you will need to use FindControl to access the textbox:

    Dim myTextbox As TextBox = CType(FormView1.FindControl("TextBox1"), TextBox)
    myTextbox.Text = myDateValue

    TextBox myTextBox = (TextBox)FormView1.FindControl("TextBox1");
    myTextbox.Text = myDateValue;

    Regards Mike
    [MVP - ASP/ASP.NET]
  • Re: itemtemplate

    05-12-2007, 7:38 PM
    Answer
    • Loading...
    • ReyN
    • Joined on 07-28-2002, 6:53 AM
    • Pilipinas
    • Posts 413

    Hello

    one other approach is to provide a Calendar control to accept date input

    on this page are several examples of the above concept. while the examples use a DetailsView,  they will work just the same with a FormView

    Reynald V. Nuñez
    aspxtreme
Page 1 of 1 (3 items)
Microsoft Communities
Page view counter