Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Datagrid ItemDatabound event ??

Reply
Thread Tools

Datagrid ItemDatabound event ??

 
 
=?Utf-8?B?c2VyZ2UgY2FsZGVyYXJh?=
Guest
Posts: n/a
 
      11-21-2005
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
 
Reply With Quote
 
 
 
 
S. Justin Gengo
Guest
Posts: n/a
 
      11-21-2005
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
"serge calderara" <(E-Mail Removed)> wrote in
message news:(E-Mail Removed)...
> 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



 
Reply With Quote
 
 
 
 
Eliyahu Goldin
Guest
Posts: n/a
 
      11-21-2005
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

"serge calderara" <(E-Mail Removed)> wrote in
message news:(E-Mail Removed)...
> 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



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
e.Item.DataItem in a ItemDataBound event (DataGrid) MattB ASP .Net 4 09-25-2006 01:48 AM
GV Databound Event vs DG ItemDataBound Event GaryDean ASP .Net 1 08-18-2006 03:47 AM
How can I reference a nested datagrid itemdatabound event? needin4mation@gmail.com ASP .Net 1 01-25-2006 06:20 PM
ItemDataBound Event - How to access the previous record when this event is raised in DataGrid? NH ASP .Net Datagrid Control 2 12-17-2004 03:58 PM
ItemDataBound event of DataGrid Dave ASP .Net 2 10-07-2004 02:54 PM



Advertisments