Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Change font row color from conditions on a datagrid

Change font row color from conditions on a datagrid

Scheduled Pinned Locked Moved ASP.NET
questionhelp
6 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    MagicGirL83
    wrote on last edited by
    #1

    hi. i'd like to ask how can i change the font color of a specific row on a datagrid based from conditions? ex: if it sees "CRITICAL" anywhere on the row, it will change the entire row's font color to red and if it sees "WARNING" to green.. etc... pls help me how can i do that? here's my code: Sub Page_Load(Sender As Object, E As EventArgs) 'some codes MyCommand = New SqlDataAdapter("SELECT ReceivedTime, SenderName, Subject FROM NewMessages where Subject not like '%alertlog%' and Subject like '%ars%' ", MyConnection) DS = new DataSet() MyCommand.Fill(ds, "NewMessages") MyDataGrid.DataSource=ds.Tables("NewMessages").DefaultView MyDataGrid.DataBind()

    MARS

    C 1 Reply Last reply
    0
    • M MagicGirL83

      hi. i'd like to ask how can i change the font color of a specific row on a datagrid based from conditions? ex: if it sees "CRITICAL" anywhere on the row, it will change the entire row's font color to red and if it sees "WARNING" to green.. etc... pls help me how can i do that? here's my code: Sub Page_Load(Sender As Object, E As EventArgs) 'some codes MyCommand = New SqlDataAdapter("SELECT ReceivedTime, SenderName, Subject FROM NewMessages where Subject not like '%alertlog%' and Subject like '%ars%' ", MyConnection) DS = new DataSet() MyCommand.Fill(ds, "NewMessages") MyDataGrid.DataSource=ds.Tables("NewMessages").DefaultView MyDataGrid.DataBind()

      MARS

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      Handle an onitemdatabound event, then you can get your row and look through it/change it's properties. Christian Graus - Microsoft MVP - C++

      M 1 Reply Last reply
      0
      • C Christian Graus

        Handle an onitemdatabound event, then you can get your row and look through it/change it's properties. Christian Graus - Microsoft MVP - C++

        M Offline
        M Offline
        MagicGirL83
        wrote on last edited by
        #3

        ohh..how can i do that? can u give an example? i'm really puzzled..thanks..:confused:

        C 1 Reply Last reply
        0
        • M MagicGirL83

          ohh..how can i do that? can u give an example? i'm really puzzled..thanks..:confused:

          C Offline
          C Offline
          Christian Graus
          wrote on last edited by
          #4

          In the aspx: Then in your page protected void OnItemDataBound(object sender, DataGridItemEventArgs e) { // e.Item is the row in question, then you can cast that to a more defined type ( TableRow probably ) and search through it/set properties/etc. // Look up OnItemDataBound in MSDN for more examples } Christian Graus - Microsoft MVP - C++

          M 1 Reply Last reply
          0
          • C Christian Graus

            In the aspx: Then in your page protected void OnItemDataBound(object sender, DataGridItemEventArgs e) { // e.Item is the row in question, then you can cast that to a more defined type ( TableRow probably ) and search through it/set properties/etc. // Look up OnItemDataBound in MSDN for more examples } Christian Graus - Microsoft MVP - C++

            M Offline
            M Offline
            MagicGirL83
            wrote on last edited by
            #5

            it's done what about adding tooltip when a user moves his mouse to a record? it will show up something from the same row from the database?

            C 1 Reply Last reply
            0
            • M MagicGirL83

              it's done what about adding tooltip when a user moves his mouse to a record? it will show up something from the same row from the database?

              C Offline
              C Offline
              Christian Graus
              wrote on last edited by
              #6

              Controls have a tooltip property. Christian Graus - Microsoft MVP - C++

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups