DataGrid: Setting row background color programatically

Discussion in 'ASP .Net Web Controls' started by M. Craig, Oct 29, 2003.

  1. M. Craig

    M. Craig Guest

    Does anyone have an example or suggestion as to how to programatically
    databind a row's background color? I understand how to use an
    asp:TemplateColumn to set the BG color on a column, but I want to
    dynamically set the BG color based on a value returned from a database

    I've tried the following with no success:
    <ItemStyle BackColor=<%# DataBinder.Eval(Container.DataItem, "color") %>
    />

    the error states that ItemStyle doesn't have a definition for DataBinder.

    Help?

    thanks.
     
    M. Craig, Oct 29, 2003
    #1
    1. Advertisements

  2. Hi

    Please check the following article
    http://www.dotnetjunkies.com/howto/default.aspx?id=27

    HTH
    Ravikanth[MVP]


    >-----Original Message-----
    >Does anyone have an example or suggestion as to how to

    programatically
    >databind a row's background color? I understand how to

    use an
    >asp:TemplateColumn to set the BG color on a column, but

    I want to
    >dynamically set the BG color based on a value returned

    from a database
    >
    >I've tried the following with no success:
    > <ItemStyle BackColor=<%# DataBinder.Eval

    (Container.DataItem, "color") %>
    >/>
    >
    >the error states that ItemStyle doesn't have a

    definition for DataBinder.
    >
    >Help?
    >
    >thanks.
    >
    >
    >.
    >
     
    Ravikanth[MVP], Oct 30, 2003
    #2
    1. Advertisements

  3. M. Craig

    M. Craig Guest

    Thanks. That looks like what I needed. I had been using the ItemDataCreated
    no the ItemDataBound method.


    "Ravikanth[MVP]" <> wrote in message
    news:094701c39ed1$c2822b50$...
    > Hi
    >
    > Please check the following article
    > http://www.dotnetjunkies.com/howto/default.aspx?id=27
    >
    > HTH
    > Ravikanth[MVP]
    >
    >
    > >-----Original Message-----
    > >Does anyone have an example or suggestion as to how to

    > programatically
    > >databind a row's background color? I understand how to

    > use an
    > >asp:TemplateColumn to set the BG color on a column, but

    > I want to
    > >dynamically set the BG color based on a value returned

    > from a database
    > >
    > >I've tried the following with no success:
    > > <ItemStyle BackColor=<%# DataBinder.Eval

    > (Container.DataItem, "color") %>
    > >/>
    > >
    > >the error states that ItemStyle doesn't have a

    > definition for DataBinder.
    > >
    > >Help?
    > >
    > >thanks.
    > >
    > >
    > >.
    > >
     
    M. Craig, Oct 30, 2003
    #3
    1. Advertisements

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:
    769
    =?Utf-8?B?TmVpbA==?=
    Oct 7, 2004
  2. Gabriël van der Kruijk

    Problem with background color of row in datagrid

    Gabriël van der Kruijk, Oct 11, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    404
    Gabriël van der Kruijk
    Oct 11, 2004
  3. Gabriël van der Kruijk

    Problem with background color of row in datagrid

    Gabriël van der Kruijk, Oct 11, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    426
    Gabriël van der Kruijk
    Oct 11, 2004
  4. G. Whiz
    Replies:
    1
    Views:
    3,033
  5. Monty
    Replies:
    3
    Views:
    5,078
    Monty
    Aug 19, 2004
  6. fig000
    Replies:
    0
    Views:
    4,741
    fig000
    Sep 6, 2004
  7. Kamaljeet Saini
    Replies:
    0
    Views:
    841
    Kamaljeet Saini
    Feb 13, 2009
  8. Replies:
    1
    Views:
    484
    marss
    Feb 14, 2007
Loading...