Setting color for a single cell in a datagrid.

Discussion in 'ASP .Net Datagrid Control' started by UJ, Aug 28, 2006.

  1. UJ

    UJ Guest

    How can I set the background color for a single cell dynamically in a
    datagrid control? I know how to do the entire row but not the cell.

    TIA - Jeff.
    UJ, Aug 28, 2006
    #1
    1. Advertising

  2. You need first to navigate to the cell and then set its BackColor property.
    Navigation to cell depends on in what place in the code you want to do it.
    If you are in the ItemDataBound event, which is the most common place for
    handling this sort of tasks, you get a reference to the datagrid item (row)
    as a parameter and you can use Cells collection to get to the cell. In
    PageLoad or PreRender event you first navigate to the row in the grid and
    then to the cell.

    --
    Eliyahu Goldin,
    Software Developer & Consultant
    Microsoft MVP [ASP.NET]


    "UJ" <> wrote in message
    news:...
    > How can I set the background color for a single cell dynamically in a
    > datagrid control? I know how to do the entire row but not the cell.
    >
    > TIA - Jeff.
    >
    >
    Eliyahu Goldin, Aug 29, 2006
    #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?T2Zlcg==?=

    set cell color while rendered in a datagrid

    =?Utf-8?B?T2Zlcg==?=, Apr 1, 2005, in forum: ASP .Net
    Replies:
    3
    Views:
    2,932
    Elton Wang
    Apr 2, 2005
  2. Empire City
    Replies:
    3
    Views:
    406
    Empire City
    Apr 30, 2004
  3. RJ
    Replies:
    1
    Views:
    238
    Eliyahu Goldin
    Feb 17, 2005
  4. fig000
    Replies:
    0
    Views:
    4,545
    fig000
    Sep 6, 2004
  5. Kamaljeet Saini
    Replies:
    0
    Views:
    410
    Kamaljeet Saini
    Feb 13, 2009
Loading...

Share This Page