We help IT Professionals succeed at work.

In VB.Net compare value from  DataGridView and return other value

PNRT
PNRT asked
on
Hi experts.   In VB.Net, 2008 and .Net 3.5.  I have a datagridview with 6 columns.   I need to iterate through column 1 and if a match is found to a string, then get the value from the same row but column 2.  An example would be appreciated.  Many Thanks in advance    
Comment
Watch Question

you can use findcontrol method of gridview datarow through looping to gridview rows (can aslo be in rowdatabound event ) for that particular value which you want for comparing also and for taking also.

Hope you get what i mean.

Author

Commented:
Hi, thanks for the reply.  I checked the findcontrol message but cant seem to see the relevance.  Im trying to get the cell value of one cell based on the contents of another cell.   Sorry if I was not clear.
I was looking for something like

for each row in datagridview1
if cell in column 1 = x then same row, column 2 = y
next

But unfortunately, I wasnt able to get that right.  Is the above not the right way to achive this.
instead of again applying conditional logic better way you can do this in your query itself provided you are binding your datagridview using sql query.

Use Case in sql query.

chk for details:

http://msdn.microsoft.com/en-us/library/ms181765.aspx

http://articles.techrepublic.com.com/5100-10878_11-5078041.html