Using the Calendar Control

Last post 04-16-2008 12:23 PM by Sonu. 3 replies.
Page 1 of 1 (4 items)
Sort Posts: Previous Next
  • 04-16-2008 11:37 AM

    • ianthm
    • Top 25 Contributor
    • Joined on 03-25-2008
    • Wannabe Slacker
    • Points 1,071

    Using the Calendar Control

    Hi and help,

    I have written the following code to insert a date from the calendar control into a database. It works fine. 

    I now wish to have 5 dates entered by clicking a calendar date but with each a different field in the same record of the database. The database will be modified to have 5 date fields.

    Can you explain how the code can be modified. I guess the solution is that each date entry/click to be recorded as date1, date2, date3 etc.. but I do not know how to do this.

    Thanks

    protected void Calendar1_SelectionChanged(object sender, EventArgs e)
        {
           
            SqlConnection conn = null;
            SqlDataReader rdr = null;
                         
            conn = new SqlConnection("Server=.;DataBase=Manage_My_Chain;Integrated Security=Yes");
            conn.Open();

            SqlCommand cmd = new SqlCommand("StoredProcedure6", conn);

            cmd.CommandType = CommandType.StoredProcedure;
                   
            cmd.Parameters.Add(new SqlParameter("@Date", Calendar1.SelectedDate));

            rdr = cmd.ExecuteReader();

     

     

     

    Filed under:
  •  Advertisement

    3 MONTHS FREE & FREE SETUP on ASP.NET 3.5/2.0 Web Hosting! Windows 2008 & 2003 Servers Available, MS SQL 2008/2005, .NET 3.5 SP1, Entity Framework, LINQ, Silverlight 2.0, 30 Day Money Back Guarantee – Click Here!

     
  • 04-16-2008 11:54 AM In reply to

    • Sonu
    • Top 10 Contributor
    • Joined on 05-22-2006
    • Montreal / Canada
    • Slacker
    • Points 10,367
    • MVP

    Re: Using the Calendar Control

    If you are using just one calendar to enter all 5 dates into the same record (row), then it will be a bit tougher. Can you use 5 different calendar controls? Can you describe what exactly the purpose is, so that I can understand and maybe suggest a better solution?

    [MVP since 2005] [MCAD]
    Webmaster of DotNetSlackers
    Question or Suggestion?
    Feel free to ask my any .NET question
    Our Posting FAQ
  • 04-16-2008 12:09 PM In reply to

    • ianthm
    • Top 25 Contributor
    • Joined on 03-25-2008
    • Wannabe Slacker
    • Points 1,071

    Re: Using the Calendar Control

     Hi Sonu,

    The purpose is to enter 5 target dates for a construction project into a data base.

    I had tried to set this up using direct entry in text boxes but was unsuccessful. The problem is I did not know how to enter dates, and when populating the data base was getting data type errors. The calender has none of these problems but then presented others.

    Thanks

     

    Ian

     

  • 04-16-2008 12:23 PM In reply to

    • Sonu
    • Top 10 Contributor
    • Joined on 05-22-2006
    • Montreal / Canada
    • Slacker
    • Points 10,367
    • MVP

    Re: Using the Calendar Control

    I think it would be better to use 5 calendar controls - disable autopostback (set it to false) and use a regular asp:button. Once the button is clicked you retrieve the dates from the all 5 calendar controls and submit them to your database. Does that make sense?

    [MVP since 2005] [MCAD]
    Webmaster of DotNetSlackers
    Question or Suggestion?
    Feel free to ask my any .NET question
    Our Posting FAQ
Page 1 of 1 (4 items)