Click here to Skip to main content
15,907,149 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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:

VB
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
Posted

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.
 
Share this answer
 
v2
Comments
snamyna 28-Jun-12 23:49pm    
I just face the problem at this part
If Convert.ToString(DataBinder.Eval(e.Row.DataItem,("LOT_NO_T")= dr.Item("LOT_NO_T")
because it cannot retrieve particular Lot No. :(
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. :)
 
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