Link to home
Create AccountLog in
Avatar of amillyard
amillyardFlag for United Kingdom of Great Britain and Northern Ireland

asked on

data gridview -- displaying / non-displaying of the Horizontal gridlines

within the data gridview -- when displaying the Horizontal gridlines, this works well in terms of slightly seperating each row....but, at the top and bottom (header/footer) this feature also adds a line aorund the entire datagrid.

as my header and footers are using a white background -- this look strange having a thin line around the edge.

question is -- how can have the rows slightly seperated, but without having these entire boxed gridlines?
Avatar of ZachSmith
ZachSmith
Flag of United States of America image

Avatar of amillyard

ASKER

ZachSmith:  this is the same as the control with vs -- i.e. drop-down options -- there appears to be no-way to change the color of the gridlines for example
For header/footer add styles as given below
GridView1.HeaderStyle.CssClass = "dbGrid";

.dbGrid TD {
border-bottom: 0px;
border-top: 0px;
}

Also with the styles you can change the UI layout as per your need.
You can change the color

.dbGrid TD {
border-top: 1px solid #99CCFF;
border-top: 0px;
}
Irzana:  wil this affect every row -- or just the header and footer.

I like the fact that gridline opens up the rows...but there is also a bolden line on left hand side that needs to be removed (along with header and footer).

by just using the css above, I think I am just affecting the header and footer ?
If you need this for evry row u can add this to row style and modify the style as per your need
`
GridView1.RowStyle.CssClass = "dbGridControl";

.dbGridControl TD {
      color: #398791;
      border-left-color :White ;
      border-left-width :0px;
      border-right-width : 0px;
}
Irzana:   where do I put this above scripting?  server-behind code or within the .aspx
Irzana: it's ok -- have worked that part out now :-)
I have tried this script -- increasing the border left/right width to 10px, so I could see any effect, but nothing is visible.

I was hoping that there would be a border around around each row.

the script is definately compiling and being actioned (as the previous script supplied affected the text color also).

have also changed the color of the row border -- just in case it was working but just could see the effect -- again nothing noticable.

why would this be so ?
  .dbGridControl TD {
      border-left-color :White ;
      border-left-width :10px;
      border-right-width : 10px;
}

Open in new window

Can you send a screenshot of your UI page?so that I can easily identify and help you on that
Irzana:  attached browser layout as requested.

what I am wanting to do is seperate each row with a thin white gap -- because as you can see when a row is highlighted with a color, the row merge and make it harder to determine which row is which.
datagrid1.jpg
try this out

.dbGridControl TD {
      border-bottom: 10px ;
      border-bottom-color : White ;
      }
using ::  GridView1.RowStyle.CssClass = "dbGridControl";

is this correct -- as no change in appearance.
yes it worked.try css given below..its taking border bottom

.dbGridControl TD {
      border-bottom: 10px ;
      border-bottom-color : White ;
      }
Irzana: have the following script -- is the correct place (at load?) ... have tried again but nothing visibally changed unfortunately yet for me.

protected void GridViewCC_MyDiaryCallBacks_Load(object sender, EventArgs e)
        {
            GridViewCC_MyDiaryCallBacks.RowStyle.CssClass = "dbGridControl";
 
            GridViewCC_MyDiaryCallBacks.Columns[3].ItemStyle.Width = 73;     // Call-Back Date
            GridViewCC_MyDiaryCallBacks.Columns[4].ItemStyle.Width = 80;     // Call-Back Time
            GridViewCC_MyDiaryCallBacks.Columns[5].ItemStyle.Width = 200;    // Primary Applicant
            GridViewCC_MyDiaryCallBacks.Columns[6].ItemStyle.Width = 375;    // Action Note Desc
        }

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Irzana
Irzana
Flag of Sri Lanka image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Irzana:  nothing's changed.

there is an additional rowdatabound  -- which is called per row ... does this interfer your scripting?  (i.e. overrride in any way?)


protected void MyGridViewCC_CallBacks_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                DateTime serverTime = service.GetServerTime();
                Int32 dayDiff = Convert.ToDateTime(e.Row.Cells[3].Text).Subtract(serverTime).Days;
 
                switch (dayDiff)
                {
                    case -1: e.Row.BackColor = Color.LightYellow;
                        e.Row.ForeColor = Color.Black;
                        break;
                    case -2: e.Row.BackColor = Color.Yellow;
                        e.Row.ForeColor = Color.Black;
                        break;
                    case -3: e.Row.BackColor = Color.LightSalmon;
                        e.Row.ForeColor = Color.Black;
                        break;
                    case -4: e.Row.BackColor = Color.Tomato;
                        e.Row.ForeColor = Color.White;
                        break;
                }
 
                if (dayDiff < -4)
                {
                    e.Row.BackColor = Color.Red;
                    e.Row.ForeColor = Color.White;
                }
 
                if (dayDiff > 0)
                {
                    e.Row.BackColor = Color.Green;
                    e.Row.ForeColor = Color.Yellow;
                }
            }
        }

Open in new window

Yes.this might be a problem.better comment this piece of code and give a backkcolor in aspx.try & see whether styles work.Its works perfectly in my PC
mmm...nothings changed...  scratching my head now
Can you attach both your aspx/cs code.I'll loook what went wrong. because its working fine when I tested