row color & Datagrid

Discussion in 'ASP .Net Datagrid Control' started by n, Jul 29, 2003.

  1. n

    n Guest

    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 ?
     
    n, Jul 29, 2003
    #1
    1. Advertising

  2. 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 ?
    >
    >
     
    Cristian Suazo, Jul 29, 2003
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?TmVpbA==?=

    DataGrid, changing background color of a Row?

    =?Utf-8?B?TmVpbA==?=, Oct 7, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    661
    =?Utf-8?B?TmVpbA==?=
    Oct 7, 2004
  2. G. Whiz
    Replies:
    1
    Views:
    2,858
  3. =?Utf-8?B?aWdvdHlvdXJkb3RuZXQ=?=

    change row color of empty row

    =?Utf-8?B?aWdvdHlvdXJkb3RuZXQ=?=, Oct 19, 2006, in forum: ASP .Net
    Replies:
    3
    Views:
    450
    Walter Wang [MSFT]
    Oct 24, 2006
  4. D
    Replies:
    0
    Views:
    220
  5. Kamaljeet Saini
    Replies:
    0
    Views:
    430
    Kamaljeet Saini
    Feb 13, 2009
Loading...

Share This Page