我想在Gridview或datalist或任何其他控件中查看出席 [英] I want to View Attendance in Gridview or datalist or any other control

查看:83
本文介绍了我想在Gridview或datalist或任何其他控件中查看出席的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的Sql考勤表就像那样

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





我想在GridView或Datalist中查看这种格式,我想在标签中的工具提示中绑定总工作时间,这样当用户将鼠标置于状态时,他们就可以显示他的总工作时间。





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....

推荐答案

如果要求查询字符串来获取数据和在gridview上显示它就是答案。



更好,最简单的方法我总是建议将DataTable定义为DataGridview的数据源并处理dataTable实例而不是DataGridView控件本身。



DataTable类有强大的方法和它直接将您的数据绑定到DataGridView,因此您对dataTable行/列所做的任何更改都会立即反映在DataGridView上。所以步骤是



1.定义一个dataTable

2.将上面的dataTable设置为dataSource到dataggridview

3.准备满足您要求的mySQL select语句

参考此链接以了解如何编写mySQL语句

http://dev.mysql.com/tech-resources/articles/subqueries_part_1.html [ ^ ]

4.使用select语句结果更新dataTable,最可能是它的DataSet / DataTable基于你如何编写你的方法

5.Thats你的所有网格将在完成第4步时显示表格数据。





所以我们已完成显示你需要在这里做的一件事是,简单地将dataTable绑定到datagridview显示我们在select语句中使用的别名作为列名和它会自动将select语句中包含的所有项目填充到有时令人讨厌的网格中。如果要配置datagrid列,使其仅显示您真正感兴趣的列。请按照以下步骤操作



1.更改dataGridView.AutoGenerateColumn = false ,这将停止添加更新select语句的列

2.添加您真正感兴趣的列

3.将DataPropertyName设置为您选择的别名声明

将自动从sql表中取出列来查看
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


这篇关于我想在Gridview或datalist或任何其他控件中查看出席的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆