在运行时的数据网格视图行单元格中显示结果?
我将数据从 Datatable 加载到 DatagridView ,如下所示:
SerialNumber1 | Quantity | Issued Quantity | Status |
00001 | 1 | | |
00002 | 2 | | |
我有这个要求,这让我陷入困境。
我需要查询数据数据网格视图记录以验证加载的序列号是否与实际相同。 (也许通过使用 linq - 如果我不正确,请纠正我)
例如:
var dgviewData = from a in gdview1.AsEnumerable()
where a<string>("SerialNumber").tostring() == txtserial.text
select a;
if(a.Count() > 0 )
{
// Update Status of SerialNumber 00001 to Ok
}
else
{
//Error Serial Not Exist on Gridview
}
如果 DGview 上的 SerialNumbers 与实际扫描的序列号相同,则状态将在运行时仅在 datagridview 行单元格上更新。
例如:DGview序列=00001--->扫描的实际单位 = 00001
SerialNumber1 | Quantity | Issued Quantity | Status |
00001 | 1 | 1 | Ok |
00002 | 2 | | |
谢谢您的问候......
I Loaded Data From Datatable to DatagridView which look like this:
SerialNumber1 | Quantity | Issued Quantity | Status |
00001 | 1 | | |
00002 | 2 | | |
I have this requirement which make me stuck .
I need to query The data data grid view records to verify if the loaded Serial Number is The Same as The Actual. (maybe by using linq - correct me if I'm incorrect)
Ex:
var dgviewData = from a in gdview1.AsEnumerable()
where a<string>("SerialNumber").tostring() == txtserial.text
select a;
if(a.Count() > 0 )
{
// Update Status of SerialNumber 00001 to Ok
}
else
{
//Error Serial Not Exist on Gridview
}
If SerialNumbers on DGview is the same on the actual serial scanned , the status will be updated in runtime on datagridview row cell only.
Eg: DGview serial = 00001 ---> actual unit scanned = 00001
SerialNumber1 | Quantity | Issued Quantity | Status |
00001 | 1 | 1 | Ok |
00002 | 2 | | |
Thanks in Regards....
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您的 LINQ 查询有点偏离,要获取匹配的行,您应该执行以下操作:
然后更新“Issued Quantity”(索引 = 2 处的单元格)只需执行以下操作:
除非您想增加该数字,否则请使用 Int32.Parse< /代码> / <代码>.TryParse。
Your LINQ query is a bit off, to get matching rows you should do:
Then to update "Issued Quantity" (cell at index = 2) simply do:
Unless you want to increment that number, then use
Int32.Parse
/.TryParse
.据我所知,我认为您需要向表单添加一个计时器,并在计时器发生事件时自动检查数据库中网格视图中现有数据的任何更新...
From what I can understand, I think you need to add a timer to the form and on the event of the timer automatically check the database on any updations for existing data in the gridview...
假设在某种情况下,您将获得扫描到的序列号。因此,一旦找到序列号,就循环遍历 DataGrid,并检查网格视图中的第一列是否等于扫描的列,如果是,则更新当前记录。
那么你实际上陷入了哪一部分呢?循环查看记录?
Lets assume that in a certain event, you will get hold of the serial number which is scanned. So as soon as you find out the serial number, loop through the DataGrid, and check if the first column in your grid view is equal to the scanned one and if yes, update the current record.
So which part you actually stuck in? Looping through the records?