Retrieve all Dates between selected Bootstrap DateRangePicker Plugin using C# and VB.Net in ASP.Net

Last Reply 11 months ago By dharmendr

Posted 11 months ago

we are using bootstrap date range picker where we select the start date and end date.

In this selected date range we want to capture all the dates between start date to end date.

Posted 11 months ago

Hi Ajayk,

Check this example. Now please take its reference and correct your code.


<html xmlns="">
<head runat="server">
    <script type="text/javascript" src=""></script>
    <script type="text/javascript" src=""></script>
    <script type="text/javascript" src=""></script>
    <link rel="stylesheet" href="" />
    <link rel="stylesheet" href="" />
    <script type="text/javascript">
        $(function () {
                autoUpdateInput: true,
                opens: 'center',
                timePicker: false,
                showDropdowns: false,
                timePicker24Hour: true,
                timePickerIncrement: 15,
                minDate: moment(),
                startDate: moment().startOf('hour'),
                endDate: moment().startOf('hour').add(32, 'hour'),
                locale: {
                    separator: "-",
                    format: 'DD/MM/YYYY',
                    "firstDay": 1
    <form id="form1" runat="server">
        <asp:TextBox runat="server" ID="txtDateRange" class="form-control" />
        <br />
        <asp:Button Text="Submit" runat="server" OnClick="Submit" class="btn btn-primary" />
        <br />
        <br />
        <asp:GridView runat="server" ID="gvDates" CssClass="table table-responsive" />



protected void Submit(object sender, EventArgs e)
    DateTime startDate = DateTime.ParseExact(txtDateRange.Text.Split('-')[0], "dd/MM/yyyy", System.Globalization.CultureInfo.InvariantCulture);
    DateTime endDate = DateTime.ParseExact(txtDateRange.Text.Split('-')[1], "dd/MM/yyyy", System.Globalization.CultureInfo.InvariantCulture);
    List<DateTime> dates = Enumerable.Range(0, (endDate - startDate).Days + 1).Select(day => startDate.AddDays(day)).ToList();
    gvDates.DataSource = dates;


Protected Sub Submit(ByVal sender As Object, ByVal e As EventArgs)
    Dim startDate As DateTime = DateTime.ParseExact(txtDateRange.Text.Split("-"c)(0), "dd/MM/yyyy", System.Globalization.CultureInfo.InvariantCulture)
    Dim endDate As DateTime = DateTime.ParseExact(txtDateRange.Text.Split("-"c)(1), "dd/MM/yyyy", System.Globalization.CultureInfo.InvariantCulture)
    Dim dates As List(Of DateTime) = Enumerable.Range(0, (endDate - startDate).Days + 1).Select(Function(day) startDate.AddDays(day)).ToList()
    gvDates.DataSource = dates
End Sub