Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Datagrid Control > row color & Datagrid

Reply
Thread Tools

row color & Datagrid

 
 
n
Guest
Posts: n/a
 
      07-29-2003
I have a datagrid with many records, and i want to give specific color to
rows (i have a boundcolum with value from 1 to 4 and i want green row when
the value is 1, red row when the value is 2 end so on...

Any idea ?


 
Reply With Quote
 
 
 
 
Cristian Suazo
Guest
Posts: n/a
 
      07-29-2003
add this to the ItemDataBound event of the datagrid:

protected Sub dgTest_ItemBound(ByVal sender As Object, ByVal e As
DataGridItemEventArgs) Handles dgTest.ItemDataBound
If Not IsNothing(e.Item.DataItem) Then
Select Case e.Item.DataItem("TheColumn")
Case 1
e.Item.BackColor = Color.Aqua
Case 2
e.Item.BackColor = Color.Azure
End Select
End If
End Sub


Cheers
Cristian



"n" <> wrote in message
news:...
> I have a datagrid with many records, and i want to give specific color to
> rows (i have a boundcolum with value from 1 to 4 and i want green row

when
> the value is 1, red row when the value is 2 end so on...
>
> Any idea ?
>
>



 
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
Changing font color from current font color to black color Kamaljeet Saini Ruby 0 02-13-2009 04:58 PM
change row color of empty row =?Utf-8?B?aWdvdHlvdXJkb3RuZXQ=?= ASP .Net 3 10-24-2006 12:11 PM
GridView: Row background color= red if row ID = 3 G. Whiz ASP .Net 1 02-24-2006 03:52 PM
ok I can do a totals row but how about a percentage row after each data row D ASP .Net Datagrid Control 0 05-23-2005 04:10 PM
Referencing Dataset row not Datagrid row Craig ASP .Net 2 11-02-2004 05:27 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57