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();
}