Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8979915
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T19:57:21+00:00 2026-06-15T19:57:21+00:00

So I am using the JQuery.datePicker example… http://www.kelvinluck.com/assets/jquery/datePicker/v2/demo/datePickerStartEnd.html I had the Jquery calendar working

  • 0

So I am using the JQuery.datePicker example…
http://www.kelvinluck.com/assets/jquery/datePicker/v2/demo/datePickerStartEnd.html

I had the Jquery calendar working fine, but it olnly allowed me to enter 1 date at a time and save it to the DB.

I want the user to select a start and a multiple date, run a loop through the dates and each day to the DB.

Slightly lost at the minute and any help would be appreciated….

Here is part of my view for my ActionResult create()//which allows the user to add a new day…

<form action ="ListHolidays" id="listHolidays" method="post">
@using (Html.BeginForm()) {
      @Html.ValidationSummary(true)
<fieldset>
    <legend>Holiday</legend>

    <div>
        @Html.LabelFor(model => model.PersonId, "Person")
    </div>

    <div>     
        @Html.DropDownListFor(model => model.PersonId,
                            new SelectList(ViewBag.Id, "Value", "Text"),
                            "---Select---"
                            )   
     @Html.ValidationMessageFor(model => model.PersonId)            
    </div>

    <div>
        @Html.LabelFor(model => model.HolidayDate)
    </div>

    <div>

        @Html.TextBoxFor(model => model.HolidayDate)

        @Html.TextBoxFor(model => model.endDate)
<script>

    $("#HolidayDate").addClass('date-pick');
    $("#endDate").addClass('date-pick');
        //$('.date-pick').datePicker//({dateFormat: 'dd-mm-yy'}).val();

        $(function () 
        {
            $('.date-pick').datePicker()
            $('#HolidayDate').bind('dpClosed',
                function (e, selectedDates) 
                {
                    var d = selectedDates[0];
                    if (d) 
                    {
                        d = new Date(d);
                        $('#endDate').dpSetStartDate(d.addDays(1).asString());
                    }
                }
        );
            $('#endDate').bind('dpClosed',
                function (e, selectedDates) 
                {
                    var d = selectedDates[0];
                    if (d) 
                    {
                        d = new Date(d);
                        $('#HolidayDate').dpSetEndDate(d.addDays(-1).asString());
                    }
                }
            );
        });



</script>

 @Html.ValidationMessageFor(model => model.HolidayDate)
    </div>

    <p>
        <input type="submit" value="Create"/>
    </p>

and my post for listHolidays:

[HttpPost]
public ActionResult listHolidays(Holiday holiday, int? PersonId, string HolidayDate, string endDate)
    {
        IList<DateTime> dates = new List<DateTime>();
        dates.Add(DateTime.Parse(HolidayDate));
        dates.Add(DateTime.Parse(endDate));
        List<DateTime> orderedDates = dates.OrderBy(d => d).ToList();

            for (int i = 0; i < orderedDates.Count; i++ )
            //if (ModelState.IsValid)
            {
                db.Holidays.AddObject(holiday);
                db.SaveChanges();
                return View();
            }

            return RedirectToAction("Index");
           // return View();
        }

The problem being in my list Holidays, im not sure how to run through the loop from start to end date, and add a new record to the DB for each one.

Please advise

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T19:57:22+00:00Added an answer on June 15, 2026 at 7:57 pm

    I’m going to give you an example of iterating from a start date to an end date and then you can plug that into your solution:

    DateTime startDate = Convert.ToDateTime("1/1/2012"),
        endDate = Convert.ToDateTime("1/30/2012");
    
    while (startDate < endDate)
    {
        // do something here with the date
    
        startDate = startDate.AddDays(1);
    }
    

    Now, one other thing to note is that you could in fact receive the startDate and endDate as DateTime because ASP.NET will do the conversion for you. If one of them is nullable then just set its type to DateTime?.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using the jQuery Date Picker plugin by Kelvin Luck ( http://www.kelvinluck.com/assets/jquery/datePicker/v2/demo/ ) and
I am using the jquery datepicker ( http://jqueryui.com/demos/datepicker/ ). The datepicker on the demo
I am using the jQuery datepicker( http://keith-wood.name/datepick.html ) and I would like to set
I am using the jQuery Datepicker( http://keith-wood.name/datepick.html ). I am trying to let the
Using the default example of Datepicker: <html lang=en> <head> <meta charset=utf-8 /> <title>jQuery UI
i'm using asual jquery-address, tabs example and want to add datepicker to the Extra
I am using an example of JQuery DatePicker from link text on my asp.net
I am using the jquery datepicker. I want to personalize this widget, for example
Using the jquery datepicker ui, the value attributes of the associated html fields don't
I am using jQuery datepicker, I have two datepicker input fields, like following: <html>

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.