Click here to Skip to main content
15,890,512 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want show days according to the month and year. This month and year are
displayed in a Dropdownlist. When I select the month and year then the appropriate days are displayed in the GridView.
Posted
Updated 30-Mar-10 21:23pm
v2

1 solution

You can find the days in a month as followng.

DateTime.DaysInMonth(year, month);


To bind the grid use following code
private void Bind(int year, int month)
	{
		int days = DateTime.DaysInMonth(year, month);
		int[] daysArray = new int[days];
		for (int i = 0; i < days; i++)
		{
			daysArray[i] = i + 1;
		}
		GridView1.DataSource = daysArray;
		GridView1.DataBind();

	}
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900