简体   繁体   中英

Remove top border of GridViewRow in c#

I am adding row controls in rowcreated event of gridview and top border line needs to be removed.

GridViewRow HeaderGridRow = new GridViewRow(0, 0, DataControlRowType.Header, DataControlRowState.Insert);
TableCell HeaderCell = new TableCell();
HeaderCell.Text = strTotalRecords;
HeaderCell.HorizontalAlign = HorizontalAlign.Left;
HeaderCell.BorderStyle = BorderStyle.None;
HeaderGridRow.Cells.Add(HeaderCell);
HeaderGridRow.BackColor = Color.White;
gvGrid.Controls[0].Controls.AddAt(totalRowIndex, HeaderGridRow);

I am using the below code to remove border and it doesn't work.

HeaderCell.Attributes.CssStyle.Add("border-top", "none");
HeaderCell.Attributes.CssStyle.Add("border-top-style", "none");

HeaderGridRow.Attributes.CssStyle.Add("border-top", "none");    
HeaderGridRow.Attributes.CssStyle.Add("border-top-style", "none");

Please suggest me how this can be handled.

add a css class to your grid and add style to that css class like below.

.gridview
{
    border-top:none !important;
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM