Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Select calendar date problem in formview.

Select calendar date problem in formview.

Scheduled Pinned Locked Moved ASP.NET
htmlhelp
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • F Offline
    F Offline
    FionaDM
    wrote on last edited by
    #1

    Sorry - this is a repost - forgot to ignore html tags. I want to embed a calendar in my a formview and pick a date from it which will be assigned to a textbox. I have a linkbutton to the initially hidden Calendar which set the mode of the Calendar to visible. OK so far. I next want to pick a date from the Calendar but so far have been unable to assign the selected date to the textbox. The errors I get are w.r.t the Calendar1_SelectionChanged method. 1. the object validToDate does not contain a definition for 'text' 2. the object cal does not contain a definition for 'SelectedDate' Here's my code: protected void Calendar1_SelectionChanged(object sender, EventArgs e) { object validToDate =null; validToDate = FormView1.FindControl("ValidToTextBox"); object cal=null; cal = FormView1FindControl("Calendar1"); validToDate.text= clnd.SelectedDate.ToShortDateString(); FormView1.FindControl("Calendar1").Visible = false; } protected void linkButton1_Click(object sender, EventArgs e) { FormView1.FindControl("Calendar1").Visible = true; }

    M 1 Reply Last reply
    0
    • F FionaDM

      Sorry - this is a repost - forgot to ignore html tags. I want to embed a calendar in my a formview and pick a date from it which will be assigned to a textbox. I have a linkbutton to the initially hidden Calendar which set the mode of the Calendar to visible. OK so far. I next want to pick a date from the Calendar but so far have been unable to assign the selected date to the textbox. The errors I get are w.r.t the Calendar1_SelectionChanged method. 1. the object validToDate does not contain a definition for 'text' 2. the object cal does not contain a definition for 'SelectedDate' Here's my code: protected void Calendar1_SelectionChanged(object sender, EventArgs e) { object validToDate =null; validToDate = FormView1.FindControl("ValidToTextBox"); object cal=null; cal = FormView1FindControl("Calendar1"); validToDate.text= clnd.SelectedDate.ToShortDateString(); FormView1.FindControl("Calendar1").Visible = false; } protected void linkButton1_Click(object sender, EventArgs e) { FormView1.FindControl("Calendar1").Visible = true; }

      M Offline
      M Offline
      Mike Ellison
      wrote on last edited by
      #2

      I noticed you are using a lot of FindControls, which I don't think you need. Try this for your Calendar1_SelectionChanged() function:

      protected void Calendar1_SelectionChanged(object sender, EventArgs e)

      {
          ValidToTextBox.Text= Calendar1.SelectedDate.ToShortDateString();
          Calendar1.Visible = false;
      }
      
      F 1 Reply Last reply
      0
      • M Mike Ellison

        I noticed you are using a lot of FindControls, which I don't think you need. Try this for your Calendar1_SelectionChanged() function:

        protected void Calendar1_SelectionChanged(object sender, EventArgs e)

        {
            ValidToTextBox.Text= Calendar1.SelectedDate.ToShortDateString();
            Calendar1.Visible = false;
        }
        
        F Offline
        F Offline
        FionaDM
        wrote on last edited by
        #3

        Mike Ellison wrote:

        I noticed you are using a lot of FindControls, which I don't think you need. Try this for your Calendar1_SelectionChanged() function: protected void Calendar1_SelectionChanged(object sender, EventArgs e) { ValidToTextBox.Text= Calendar1.SelectedDate.ToShortDateString(); Calendar1.Visible = false; }

        Yes - you do need to use FindControl to find a control in FormView or DetailsView etc. That will work outside the FormView. Anyway I've figured it out. protected void Calendar1_SelectionChanged(object sender, EventArgs e) { TextBox validToDate; Calendar cal; validToDate=(TextBox)FormView1.FindControl("ValidToTextBox"); cal = (Calendar)FormView1.FindControl("Calendar1"); validToDate.Text = cal.SelectedDate.ToShortDateString(); FormView1.FindControl("Calendar1").Visible = false; } Perhaps there's a neater or better way as I'm pretty new to this. But it works. Maj

        M 1 Reply Last reply
        0
        • F FionaDM

          Mike Ellison wrote:

          I noticed you are using a lot of FindControls, which I don't think you need. Try this for your Calendar1_SelectionChanged() function: protected void Calendar1_SelectionChanged(object sender, EventArgs e) { ValidToTextBox.Text= Calendar1.SelectedDate.ToShortDateString(); Calendar1.Visible = false; }

          Yes - you do need to use FindControl to find a control in FormView or DetailsView etc. That will work outside the FormView. Anyway I've figured it out. protected void Calendar1_SelectionChanged(object sender, EventArgs e) { TextBox validToDate; Calendar cal; validToDate=(TextBox)FormView1.FindControl("ValidToTextBox"); cal = (Calendar)FormView1.FindControl("Calendar1"); validToDate.Text = cal.SelectedDate.ToShortDateString(); FormView1.FindControl("Calendar1").Visible = false; } Perhaps there's a neater or better way as I'm pretty new to this. But it works. Maj

          M Offline
          M Offline
          Mike Ellison
          wrote on last edited by
          #4

          Oh - I got it. I missed the FormView part.

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups