Click here to Skip to main content
15,907,687 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
i want to display monthly attendance report of students on grid view. for that i want to display dates of selected month in header row of grid view.. how can i do it??

What I have tried:

i have tried it on rowbound event of gridview but not able to display or bind date of selected month from dropdown of month...pls.. help..
Posted
Updated 19-Apr-16 11:16am
v2
Comments
Karthik_Mahalingam 19-Apr-16 7:14am    
so you need to display like mon tue wed... instead of 1 2 3.....?
Member 12470215 19-Apr-16 13:03pm    
i want to display dates in header like 1 2 3 ...31 that must be change by selection of a particular month..and in data row attendance like absent or present for each date.
Karthik_Mahalingam 19-Apr-16 20:57pm    
create a datatabe in that manner and bind it .
Member 12003400 19-Apr-16 9:15am    
Take onrowcommandevent and bind grid again on selected value.

1 solution

This article shows you how to add columns dynamically to a GridView - how to create columns dynamically in a grid view[^]

To get the list of dates for the month just use a simple for-loop from 1 to DateTime.DaysInMonth(Int32, Int32)[^]

To get a month name as an integer to use in the DaysInMonth method try
C#
var monthNo = DateTime.ParseExact(MonthName, "MMMM", CultureInfo.InvariantCulture).Month;

(You might want to use CurrentCulture instead of InvariantCulture depending on which language you are using to display MonthName)
 
Share this answer
 

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