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. Is it possible to select date from the calendar and put the date to the detailsview?

Is it possible to select date from the calendar and put the date to the detailsview?

Scheduled Pinned Locked Moved ASP.NET
csharpquestiondatabasedesign
3 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.
  • B Offline
    B Offline
    blurMember
    wrote on last edited by
    #1

    The subject is abit incorrect. Let me describe briefly; I am doing a project in .NET 2.0. C#. I have DetailsView control where user can add date and occasion to the database, thus display it in a gridview. But I wish that user can select the date from the calendar instead of typing. What is the correct syntax to write the code when the date is selected from the calendar? protected void Calendar1_SelectionChanged(object sender, EventArgs e) { //DetailsView1. = Calendar1.SelectedDate.ToString("dd MMM yyyy"); } the source from design view thanks in advance. Much appreciated.

    M 1 Reply Last reply
    0
    • B blurMember

      The subject is abit incorrect. Let me describe briefly; I am doing a project in .NET 2.0. C#. I have DetailsView control where user can add date and occasion to the database, thus display it in a gridview. But I wish that user can select the date from the calendar instead of typing. What is the correct syntax to write the code when the date is selected from the calendar? protected void Calendar1_SelectionChanged(object sender, EventArgs e) { //DetailsView1. = Calendar1.SelectedDate.ToString("dd MMM yyyy"); } the source from design view thanks in advance. Much appreciated.

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

      Hi there. One suggestion is to substitute a TemplateField for your date's BoundField, add a TextBox and Calendar control to the EditTemplate, then use something like this for code:

      protected void Calendar1_SelectionChanged(object sender, EventArgs e)
      {
      // use the textbox's ID for "TextBox1" below"
      TextBox tb = (TextBox)DetailsView1.FindControl("TextBox1")
      tb.Text = Calendar1.SelectedDate.ToString("dd MMM yyyy");
      }

      B 1 Reply Last reply
      0
      • M Mike Ellison

        Hi there. One suggestion is to substitute a TemplateField for your date's BoundField, add a TextBox and Calendar control to the EditTemplate, then use something like this for code:

        protected void Calendar1_SelectionChanged(object sender, EventArgs e)
        {
        // use the textbox's ID for "TextBox1" below"
        TextBox tb = (TextBox)DetailsView1.FindControl("TextBox1")
        tb.Text = Calendar1.SelectedDate.ToString("dd MMM yyyy");
        }

        B Offline
        B Offline
        blurMember
        wrote on last edited by
        #3

        Hey thanks Mike!

        Mike Ellison wrote:

        add a TextBox and Calendar control to the EditTemplate

        I just add the calendar control to the webform as usual and it works pretty fine. I hope it does not have any further errors.

        Another Genius solving my question

        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