Click here to Skip to main content
15,881,882 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have to select month of a calendar, columns must be automatically generate in grid view with respect to the no of days of selected month and year using asp.net with C#. I got the no of days in a month. If i select "may" 31 columns must be generated in gridview. If i select "June" 30 columns must be generated in gridview.
Posted
Comments
[no name] 19-Oct-12 0:24am    
Okay and? Perhaps you meant to ask some sort of a question?
AishwaryaShetty 19-Oct-12 1:08am    
I dint get you.?. Can you check it out once.
[no name] 19-Oct-12 5:56am    
I did check it out. That exactly how I knew that you did not ask any sort of a question.

1 solution

Try this..

may help u.


Int32 day,mon,yr;
//Public declaration


// on any event where u need to generate

BoundField bf = new BoundField();
       mon = Calendar1.SelectedDate.Month;
       yr = Calendar1.SelectedDate.Year;
       day = DateTime.DaysInMonth(yr, mon);
       for (int i = 1; i <= day; i++)
       {
           GridView1.Columns.Add(bf);
       }
 
Share this answer
 
Comments
AishwaryaShetty 19-Oct-12 8:28am    
I tried it but its not generating columns in gridview. Should i add any namespace?

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