如果列项目等于sql结果vb.net,则突出显示行 [英] highlight row if column item equals sql result vb.net

查看:82
本文介绍了如果列项目等于sql结果vb.net,则突出显示行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好
我有一个SQL查询来检索很多批号.
我有一个gridview,它将显示所有批号.
如何在gridview中突出显示与SQL中没有检索到的批次匹配的批次编号?

这是我的代码:

Hye all
I have a SQL query to retrieve some lot no.
I have a gridview which it will display all lot no.
How can I highlight lot no in gridview that match lot no retrieved in SQL?

This is my piece of code:

Public Sub gdLotScan_OnRowDataBound(sender As Object, e As GridViewRowEventArgs)
Dim sqlAlert As String = " SELECT LOT_NO_T FROM Q_ALERT_URGENT"
Dim dtAlert As DataTable = DBLayer.Util.Data.MsSql.DBFunction.BuildDataTable(sqlAlert, DBLayer.ClsConnection.getConnString("EPJ_SETTING_TRANS"))
For Each dr As DataRow In dtAlert.Rows
If Convert.ToString(DataBinder.Eval(e.Row.DataItem,("LOT_NO_T")= dr.Item("LOT_NO_T")Then
e.Row.BackColor = System.Drawing.Color.LightBlue
End If
Next
End Sub

推荐答案

如果您想直接在GridView中搜索-请通过本文 [ ^ ].

您还可以搜索数据源,找到合适的行,然后在网格中突出显示相应的行.

GridView-搜索控件 [
IF you want to search directly in the GridView - go through this article[^].

You could also search through the datasource, find the appropriate row and then highlight the corresponding row in the grid.

GridView-Search Control[^] is an example where a search has been implemented along with the GridView.


我已经用我的方式解决了这个问题.我只是创建一个视图并进行左外部联接.
如果列等于NULL值,则突出显示行颜色.
无论如何,您都会获得TQ. :)
I have solved this using my way.. I just create a view and do the left outer join.
If the column equals NULL value, then the row color is highlighted.
TQ for ur response anyway. :)


这篇关于如果列项目等于sql结果vb.net,则突出显示行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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