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. Advertising

  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. Advertising

  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. 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:
    637
    =?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:
    332
    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:
    360
    Gabriël van der Kruijk
    Oct 11, 2004
  4. G. Whiz
    Replies:
    1
    Views:
    2,838
  5. fig000
    Replies:
    0
    Views:
    4,527
    fig000
    Sep 6, 2004
Loading...

Share This Page