naveenkohli,
Thanks - I will see if I can decode the C# into vb and let you know.
Main Topics
Browse All TopicsI have been struggling with this and am frustrated that it isn't easier (or I am not smarter).
What I am trying to accomplish is I have a page of fixed items that I want to vary the color if they show up in a SQL query. I have tried a datalist and now using several gridviews to post the data into.
For example:
SHELF1 SHELF2 SHELF3 <--- These are individual gridviews (shelf1, shelf2, etc)
ABC DEF GHI
JKL MNO QRP
When I click a button I will execute a SQL query to a database and if any of the results contain an item in any of the gridviews it will change the item's cell color so as to indicate a match. So I need to loop through each gridview and if there is a match then color, if not then move to the next gridview.
This sounds so simple but not sure if the way I have laid it out will work. I had to break this down into multiple gridviews since I do not want a single column with over 60 rows. And when I tried a dataview someone told me I could not change the item color.
This is webforms, VB 2005
Help! Please?
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Thanks both, I found a site that converted the C# to VB. What it provided is listed below:
--------------------------
Protected Sub OnRowCreated(ByVal sender As Object, ByVal e As GridViewRowEventArgs)
If e.Row.RowType = DataControlRowType.DataRow
Dim drv As Data.DataRowView = TryCast(e.Row.DataItem, Data.DataRowView)
Dim ob As Object = drv("Weight")
If Not Convert.IsDBNull(ob) Then
Dim dVal As Double = 0.0F
If [Double].TryParse(ob.ToStr
If dVal > 3.0F Then
Dim cell As TableCell = e.Row.Cells(1)
cell.CssClass = "heavyrow"
cell.BackColor = System.Drawing.Color.Orang
End If
End If
End If
End If
End Sub
--------------------------
What I needed is code which will allow me to search each gridview and compare to the returned values provided by the SQL query. Then if a match is made it will change the background color. In the sample provided by the link it looks like it is looking for a hard coded value.
I would suggest, perhaps, a query to your db in the page load and set this as a dataset. You should be able to reference this dataset outside of that sub if you declare it in the class itself, rather than in the sub. Then, in your OnRowCreated sub, you can cycle through the dataset for each row/cell that you want and perform your highlighting then.
Does that make sense?
I am hitting a wall.....
In the example I provided how would I search for, say, 'MNO' which resides under the SHELF2 gridview?
In this example I want to search through all of the rows in SHELF2 and when I find the cell or row that contains 'MNO' do something with it.
If you could provide code it would help......
All,
Well I must be well off the beaten path. Either what I am trying to do is not possible or I am not explain it very well.....
When my page loads it populates the various gridviews with data from an Access source (so I can't use the above in a Page load). I have to wait until the data is populated in the gridviews before I do the next step which is to execute another query against another source and if that query returns data to compare against all of the gridviews and if it finds a match to change the background color.
So the comparison must
1) compare the current gridview items against the results of a query
2) step through each gridview and look at the values in each row, cell
3) change the background color if it has a match
If the gridview is not the way to go - let me know......
Business Accounts
Answer for Membership
by: naveenkohliPosted on 2007-12-06 at 05:10:39ID: 20419171
See if this helps..
evelopment / gridviewf ormatcolum n.aspx
http://www.netomatix.com/d
There are other articles on data grid and view as well.