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. Dynamically changing a cell's look in a datagrid

Dynamically changing a cell's look in a datagrid

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

    Hi There, I've created a little online calendar to help some of my coworkers keep track of shipping trucks. I have everything in place where it dynamically creates 3 tables each linked to last week, this week, and next week. I then create the datagrids and bind them to the tables. I used seperate tables just for the look because I wanted "this week" to appear larger and bolder in the middle of the other two weeks. Is there any way I can have the "this week" change the border color of the single cell depending on the current day of the week? How can you specify a certain cell in a datagrid control? Thank you!

    "You're damned if you do, and you're damned if you dont" - Bart Simpson

    C 1 Reply Last reply
    0
    • C compninja25

      Hi There, I've created a little online calendar to help some of my coworkers keep track of shipping trucks. I have everything in place where it dynamically creates 3 tables each linked to last week, this week, and next week. I then create the datagrids and bind them to the tables. I used seperate tables just for the look because I wanted "this week" to appear larger and bolder in the middle of the other two weeks. Is there any way I can have the "this week" change the border color of the single cell depending on the current day of the week? How can you specify a certain cell in a datagrid control? Thank you!

      "You're damned if you do, and you're damned if you dont" - Bart Simpson

      C Offline
      C Offline
      compninja25
      wrote on last edited by
      #2

      Actually, I think I may have just figured it out. Using my gridview, I can do something like this.

      if (DateTime.Today.DayOfWeek.ToString() == "Tuesday")
      {
      gridview2.Rows[1].BorderColor = System.Drawing.Color.Blue;
      }

      So, I just need to do a check to see what day it is and then convert that to a numeric 0 - 4 for the column specification.

      "You're damned if you do, and you're damned if you dont" - Bart Simpson

      B C 2 Replies Last reply
      0
      • C compninja25

        Actually, I think I may have just figured it out. Using my gridview, I can do something like this.

        if (DateTime.Today.DayOfWeek.ToString() == "Tuesday")
        {
        gridview2.Rows[1].BorderColor = System.Drawing.Color.Blue;
        }

        So, I just need to do a check to see what day it is and then convert that to a numeric 0 - 4 for the column specification.

        "You're damned if you do, and you're damned if you dont" - Bart Simpson

        B Offline
        B Offline
        Brij
        wrote on last edited by
        #3

        You are correct.You can also change the color at RowDataBound event.Test it taking todays date whether you getting wat you want or not

        Cheers!! Brij

        1 Reply Last reply
        0
        • C compninja25

          Actually, I think I may have just figured it out. Using my gridview, I can do something like this.

          if (DateTime.Today.DayOfWeek.ToString() == "Tuesday")
          {
          gridview2.Rows[1].BorderColor = System.Drawing.Color.Blue;
          }

          So, I just need to do a check to see what day it is and then convert that to a numeric 0 - 4 for the column specification.

          "You're damned if you do, and you're damned if you dont" - Bart Simpson

          C Offline
          C Offline
          compninja25
          wrote on last edited by
          #4

          Ah, I was close. I was able to get this to work by doing this:

          gridview2.Rows[0].Cells[2].BorderColor = System.Drawing.Color.Blue;

          "You're damned if you do, and you're damned if you dont" - Bart Simpson

          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