Click here to Skip to main content
15,881,089 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have table called attendancemast which have empid,Adate and type(P,A) field.I want to display attendance of all employees in a gridview.In which the first column header will be the employee name and other column header will be the dates of a month and last header will show the total number of present days of any employee of that month.


EmpName   01/04/2014  02/04/2014  03/04/2014 .......................................Total 
Sandip       P          P           A                                                 2
Sumit        A          A           P                                                 1


Can you help me
Posted
Updated 10-Apr-14 11:48am
v2

1 solution

I would break the problem down as follows:

1. Use DateTime.DaysInMonth to get the number of days in the selected month. For more info on this, please see: http://msdn.microsoft.com/en-us/library/system.datetime.daysinmonth.aspx[^]

2. Based on the number of days, dynamically add your columns. For an example, please see: how to create columns dynamically in a grid view[^]

3. The total column may be approached in a couple of different ways; use a formula (challenging, but doable), or for each row simply loop thru the columns and count the cells flagged as present.
 
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