I have a requirement where i need to get the users to select from a dropdown. the Dropdown will contain the weekstart date - weekenddate.The user will not be able to see the same week or previous weeks also he should be able to see just 4 weeks in the dropdown and not more than that .I require the solution in asp.net in C# > could anyone help me.
Asked
Active
Viewed 2,693 times
-4
-
For starters, you're going to need to determine what day of the week will each week start with? – nycdan Dec 29 '11 at 16:29
-
3This site is not intended to ask others to write your code for you. Could you at least demonstrate something you have attempted and what isn't working properly in your current method? – lsuarez Dec 29 '11 at 16:32
-
Related thread - http://stackoverflow.com/questions/38039/how-can-i-get-the-datetime-for-the-start-of-the-week – KV Prajapati Dec 29 '11 at 16:35
3 Answers
2
Something like:
DateTime start=DateTime.Today;// Adjust to your start date
for(int x=0;x<4;x++) {
myDropDownList.Items.AddItem(string.Format("{0} - {1}",start.ToString("MM/dd/yyyy"), start.AddDays(7).ToString("MM/dd/yyyy"));
start=start.AddDays(7);
}

Law Metzler
- 1,205
- 9
- 11
0
This article, http://forums.asp.net/post/2892686.aspx, is not an exact match for what you are asking for but it has a lot of similarities (dropdownlist, weeks of the year, c#). Hopefully it can get you in the right direction.

Peter
- 9,643
- 6
- 61
- 108
0
While I agree you need to do a bit of research before asking something this easy to find, here is the reward for your lack of effort, a link
How to get the current week starting date and add it to a combo box?