Datagrid ItemDatabound event ??

G

Guest

Dear all,

What is the way to check the value of a particular item in a particular cell
and then set its forground property in red in case of a certain value ??

I have done the following but do dot work :

============================
Select Case e.Item.ItemType
Case ListItemType.Item

If IsNumeric(e.Item.Cells(e.Item.ItemIndex).Text) Then
If CInt(e.Item.Cells(e.Item.ItemIndex).Text) = 945370550
Then
e.Item.BackColor = Color.Red
e.Item.ForeColor = Color.White

End If
End If
End Select

what dis I miss ?

thnaks for your help
regards
serge
 
S

S. Justin Gengo

Serge,

Your first step should be to remove your check for is numeric and that the
text is equal to 945370550 to see if every cell is then colored. That will
let you know if the problem is that the cell isn't being colored or if one
of your checks is not written correctly.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
 
E

Eliyahu Goldin

e.Item.ItemIndex is the index of the item in the datagrid's Items
collection. It has nothing to do with Cells collection. To get to a cell,
you need to specify it's column number, 0-based. For example,
e.Item.Cells(3) points to the 4th cell in the row.

Eliyahu
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top