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 7163705
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T13:56:51+00:00 2026-05-28T13:56:51+00:00

I want to populate the weeks in a dropdown list when selecting month like

  • 0

I want to populate the weeks in a dropdown list when selecting month like
when I select

January 

Then it will show only the weeks which starts from monday like

1st week:
Monday(02/01/2012)
2nd week:
Monday(09/01/2012)
3rd week:
Monday(16/01/2012)
4th week:
Monday(23/01/2012)
5th week:
Monday(30/01/2012)
  • 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-05-28T13:56:51+00:00Added an answer on May 28, 2026 at 1:56 pm

    So it sounds like you need to find the first Monday in the week, then just keep adding one week until you’re not in the same month any more:

    using System;
    using System.Collections.Generic;
    
    class Test
    {
        static void Main(string[] args)
        {
            foreach (DateTime date in GetMondays(2012, 1))
            {
                Console.WriteLine(date);
            }
        }
    
        static IEnumerable<DateTime> GetMondays(int year, int month)
        {
            DateTime startOfMonth = new DateTime(year, month, 1);
    
            // Get to the first Monday
            int daysToMonday = DayOfWeek.Monday - startOfMonth.DayOfWeek;
    
            // Now make sure it's non-negative...
            int daysToNextMonday = (daysToMonday + 7) % 7;
    
            // Add it to the start of the month to get to the first Monday
            DateTime firstMonday = startOfMonth.AddDays(daysToNextMonday);
    
            // Now yield and iterate until we're done
            for (DateTime date = firstMonday;
                 date.Month == month;
                 date = date.AddDays(7))
            {
                yield return date;
            }
        }
    }
    

    (You could add the dates to a list and return that instead if you wanted… it doesn’t make much difference really.)

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

Sidebar

Related Questions

I'm writing a bit of code that I want to populate a TreeView, which
I want to populate a DropDown control on page load using AJAX. I have
I want to populate a TreeView with UserControls, but I only want the Name
I want to populate a spinner with some values from a List The list
I have a table view which i want to populate with the results (XML)
I want to populate a collection from an json file, which has other data
I want to populate a JComboBox with file names of a directory. Then, if
i want to populate the tablecell with title and imageurl from xml list. i
Want to populate dynamically combobox-listbox-drop-down using javascript. var table = document.createElement(table); var select =
I want to populate a String array in a do while statement like below,

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.