Click here to Skip to main content
15,892,298 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
My Sql attendance table is like that
AtID InTime OutTIme   TotalworkingTime date       Status EmpID
1    13:45  13:46     00:01            2012-12-05 P      1
7    18:08  18:10     00:02	       2012-12-06 P      1


I want to look in this format in GridView or Datalist and i want to bind total working hour in a tooltip in label so that when ever user hove mouse on status then they can show his total working time.

Month/Date 1  2  3  4  5 6  7  8  9  10  11  12  13  14  15  16  17  18  19 20 21 22
January    P  P  P  P  P A  A  P  P   P   P   P
February
March
April
May
June
...........


Thank You....
Posted
Updated 6-Dec-12 21:46pm
v2
Comments
Gajendra Yadav 7-Dec-12 12:20pm    
you can use gridview for this type ouput....
Jibesh 7-Dec-12 20:20pm    
so whats your question here. you mentioned you want to display in gridview which is fine, You mean how to write a MySQL query to match this display?
Ravi Kumar 11-Dec-12 2:02am    
yes..

1 solution

If you asking for a query string to fetch the data and display it on gridview here is the answer.

The better and the simplest approach that I always suggest is to define a DataTable as datasource to the DataGridview and work on the dataTable instance rather than the DataGridView control itself.

the DataTable class has powerfull methods and it directly binds your data to the DataGridView so any changes you made to the dataTable rows/columns it will reflect immediately on the DataGridView. so the steps are

1. Define a dataTable
2. set the above dataTable as dataSource to the dataggridview
3. Prepare the mySQL select statement which satisfies your requirement
ref this link for how to write mySQL statements
http://dev.mysql.com/tech-resources/articles/subqueries_part_1.html[^]
4.update the dataTable with the select statement result, most probably its a DataSet/DataTable based on how you write your method
5.Thats all your grid will display the table data on completing step 4.


so we have done with display one thing you need to take here is, simply binding the dataTable to datagridview displays the alias name we used in the select statement as Column Name and it automatically populated all the items included in the select statement to the grid which is nasty at times. If you want to configure your datagrid columns so that it displays only columns which you are really interested in. follow the below steps

1. Change the dataGridView.AutoGenerateColumn = false, this will stop adding the columns on updating the select statement
2. Add the columns which you are really interested
3. Set the DataPropertyName as your Alias name from the select statement
which will automatically take the column from the sql table to view
 
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