在datagridview中需要帮助 [英] need help in datagridview

查看:71
本文介绍了在datagridview中需要帮助的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好

我正在gridview中显示出勤详细信息..但是我只想输入一天..
表示今天我输入的内容应该只显示..明天,如果我打开表格,它应该是一个空网格..
网格仅包含每天的数据...

请告诉我该怎么做..

Hi all

i am displaying attendance detail in a gridview..but i want only one days entry..
means today what ever i am entering it should show that only..tomorrow if i open the form it should be an empty grid..
grid contains each days data only...

please tell me how to do this..

推荐答案

如果您要从sql服务器或任何后端获取数据以在gridview中显示,则必须为此编写查询.查询应获取当前日期数据.
就像
if you are ferching data from sql server or any backend to dispaly in gridview then you have to write query for that. Query should fetch the current dates data.
like
select * from table_name where date = getdate()




当我们为dataset 分配任何表时,datagridview 会显示数据,因此,如果您要通过查询检索出勤日期,请输入带日期的where条件,并将其与Now.date进行比较,以便显示数据当前日期的日期和一天的开始,因此将没有数据,因此将显示一个空网格.
Hi,

datagridview shows the data when we assign any table of dataset to it so if you are retreiving the date of attendance by a query so please put a where condition with date and compare it with Now.date so it will display the data of the current date and at the start of the day there will be no data so it will show an empty grid.


为此,您需要更改获取数据的方式来绑定网格视图.
例如,如果使用存储过程,则需要添加某些条件,以便它仅获取当前日期的数据.
再次,您应该在表中有一列,当您向表中插入新数据时,该列将存储当前日期.
For this you need to alter the way you are fetching data to bind the grid view.
For example, if you are using a stored procedure, you need to add certain condition , so that it will fetch only current date''s data only.
And again , you should have a column in the table which will store the current date when you insert a new data to the table.


这篇关于在datagridview中需要帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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