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. Chage row color, image on conditions and a default string if emply in Datagrid

Chage row color, image on conditions and a default string if emply in Datagrid

Scheduled Pinned Locked Moved ASP.NET
helpquestion
2 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.
  • A Offline
    A Offline
    awu25
    wrote on last edited by
    #1

    I am trying to do something like yahoo emial. If the email has not been read display the row in white and image "A" at beginig of the row else display in light blue and display image "B" If the subject line is empty then display a string "none" so user can have something to click on to read the email. Is this possible with datagrid? If not please let me know so I don't have to waste my time trying to find a solution for an unsolvable problem.

    N 1 Reply Last reply
    0
    • A awu25

      I am trying to do something like yahoo emial. If the email has not been read display the row in white and image "A" at beginig of the row else display in light blue and display image "B" If the subject line is empty then display a string "none" so user can have something to click on to read the email. Is this possible with datagrid? If not please let me know so I don't have to waste my time trying to find a solution for an unsolvable problem.

      N Offline
      N Offline
      NewSilence
      wrote on last edited by
      #2

      awu25 wrote: If the email has not been read display the row in white and image "A" at beginig of the row else display in light blue and display image "B" Create templete clmn in your DG then add tag and check it run as a server control and add your own ItemDataBound event hander of DG Private Sub DataGrid1_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles DataGrid1.ItemDataBound If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType = ListItemType.AlternatingItem Then Dim r As DataRow = CType(e.Item.DataItem, DataRowView).Row Dim img As System.Web.UI.WebControls.Image = e.Item.FindControl("img1") If IsMailRead(r("ID")) Then e.Item.Attributes.Add("style", "background-color:white") img.ImageUrl = "/imgA.gif" Else e.Item.Attributes.Add("style", "background-color:grey") img.ImageUrl = "/imgB.gif" End If

      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