Click here to Skip to main content
11,411,241 members (62,746 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#2.0 ASP.NET
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 18-Oct-12 19:17pm
Comments
Wes Aday at 19-Oct-12 0:24am
   
Okay and? Perhaps you meant to ask some sort of a question?
AishwaryaShetty at 19-Oct-12 1:08am
   
I dint get you.?. Can you check it out once.
Wes Aday at 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

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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);
        }
  Permalink  
Comments
AishwaryaShetty at 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)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 189
1 Maciej Los 108
2 OriginalGriff 88
3 Sascha Lefévre 85
4 BillWoodruff 80
0 Sergey Alexandrovich Kryukov 8,920
1 OriginalGriff 6,918
2 Maciej Los 3,390
3 Abhinav S 3,248
4 Peter Leow 3,059


Advertise | Privacy | Mobile
Web03 | 2.8.150414.5 | Last Updated 19 Oct 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100