changing the color of a cell in a datagrid

Discussion in 'ASP .Net' started by Franck, Oct 11, 2005.

  1. Franck

    Franck Guest

    hello,
    I'm trying to change the color of certain cells
    in a datagrid according to their values?

    I tried to get the value in the Datagrid_ItemCreated event but I couldn't

    I don't know where else to start?

    any help?
    thank you
     
    Franck, Oct 11, 2005
    #1
    1. Advertising

  2. what was wrong with the _ItemCreated call?
    Also, look at the _ItemBound (or is it _ItemDataBound?) event.

    --
    Curt Christianson
    site: http://www.darkfalz.com
    blog: http://blog.darkfalz.com



    "Franck" wrote:

    > hello,
    > I'm trying to change the color of certain cells
    > in a datagrid according to their values?
    >
    > I tried to get the value in the Datagrid_ItemCreated event but I couldn't
    >
    > I don't know where else to start?
    >
    > any help?
    > thank you
    >
     
    =?Utf-8?B?Q3VydF9DIFtNVlBd?=, Oct 11, 2005
    #2
    1. Advertising

  3. Franck

    Nishanthan Guest

    HI,
    You cant do it in the Item created event. You should do it in the itembound
    event.
    Regards,
    P.Nishanthan


    "Franck" <> wrote in message
    news:digjjp$kr5$...
    > hello,
    > I'm trying to change the color of certain cells
    > in a datagrid according to their values?
    >
    > I tried to get the value in the Datagrid_ItemCreated event but I couldn't
    >
    > I don't know where else to start?
    >
    > any help?
    > thank you
     
    Nishanthan, Oct 11, 2005
    #3
  4. Curt_C [MVP] wrote:
    > what was wrong with the _ItemCreated call?
    > Also, look at the _ItemBound (or is it _ItemDataBound?) event.


    In the ItemCreated event the data's not yet been bound to the
    DataGridItem, so you can't reference the data. Hence you need to use
    the ItemDataBound event, as you noted.



    --

    Scott Mitchell [ASP.NET MVP]

    http://www.4GuysFromRolla.com/ScottMitchell
     
    Scott Mitchell [MVP], Oct 11, 2005
    #4
  5. Franck wrote:
    > I'm trying to change the color of certain cells
    > in a datagrid according to their values?
    >
    > I tried to get the value in the Datagrid_ItemCreated event but I couldn't


    You need to use the ItemDataBound event.

    Here's a FAQ that shows how to accomplish just what you're after
    (coloring a cell based on the data in the cell):
    http://datawebcontrols.com/faqs/CustomizingAppearance/ConditionalFormatting.shtml

    hth

    --

    Scott Mitchell [ASP.NET MVP]

    http://www.4GuysFromRolla.com/ScottMitchell
     
    Scott Mitchell [MVP], Oct 11, 2005
    #5
  6. ItemDataBound and PreRender are the right events to use.

    Eliyahu

    "Franck" <> wrote in message
    news:digjjp$kr5$...
    > hello,
    > I'm trying to change the color of certain cells
    > in a datagrid according to their values?
    >
    > I tried to get the value in the Datagrid_ItemCreated event but I couldn't
    >
    > I don't know where else to start?
    >
    > any help?
    > thank you
     
    Eliyahu Goldin, Oct 11, 2005
    #6
  7. Depending on where the data is coming from though....

    But yeah, you are right. The Bound is the better place.

    --
    Curt Christianson
    site: http://www.darkfalz.com
    blog: http://blog.darkfalz.com



    "Scott Mitchell [MVP]" wrote:

    > Curt_C [MVP] wrote:
    > > what was wrong with the _ItemCreated call?
    > > Also, look at the _ItemBound (or is it _ItemDataBound?) event.

    >
    > In the ItemCreated event the data's not yet been bound to the
    > DataGridItem, so you can't reference the data. Hence you need to use
    > the ItemDataBound event, as you noted.
    >
    >
    >
    > --
    >
    > Scott Mitchell [ASP.NET MVP]
    >
    > http://www.4GuysFromRolla.com/ScottMitchell
    >
     
    =?Utf-8?B?Q3VydF9DIFtNVlBd?=, Oct 11, 2005
    #7
  8. Franck

    Franck Guest

    thanks for your help
    exactly what I needed :)

    Scott Mitchell [MVP] wrote:
    > Franck wrote:
    >
    >> I'm trying to change the color of certain cells
    >> in a datagrid according to their values?
    >>
    >> I tried to get the value in the Datagrid_ItemCreated event but I couldn't

    >
    >
    > You need to use the ItemDataBound event.
    >
    > Here's a FAQ that shows how to accomplish just what you're after
    > (coloring a cell based on the data in the cell):
    > http://datawebcontrols.com/faqs/CustomizingAppearance/ConditionalFormatting.shtml
    >
    >
    > hth
    >
     
    Franck, Oct 12, 2005
    #8
    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. sck10
    Replies:
    2
    Views:
    1,219
    sck10
    Jan 11, 2007
  2. Hal Vaughan
    Replies:
    5
    Views:
    30,053
  3. Chanman
    Replies:
    0
    Views:
    989
    Chanman
    Jun 19, 2008
  4. Mufasa
    Replies:
    2
    Views:
    462
    Mufasa
    Jul 3, 2008
  5. Kamaljeet Saini
    Replies:
    0
    Views:
    463
    Kamaljeet Saini
    Feb 13, 2009
Loading...

Share This Page