我只是想我会把它作为一个解决方案发布,以防其他人想要这样做。
这是我的 CSS
<style type="text/css">
.LeftUpperCorner
{
border-left:5px solid black;
border-top:5px solid black;
}
.Top
{
border-top:5px solid black;
}
.RightUpperCorner
{
border-right:5px solid black;
border-top:5px solid black;
}
.Left
{
border-left:5px solid black;
}
.Right
{
border-right:5px solid black;
}
.LeftLowerCorner
{
border-left:5px solid black;
border-bottom:5px solid black;
}
.Bottom
{
border-bottom:5px solid black;
}
.RightLowerCorner
{
border-right:5px solid black;
border-bottom:5px solid black;
}
和我背后的代码:
if (e.Row.RowIndex == 2)
{
e.Row.Cells[1].CssClass = "LeftUpperCorner";
e.Row.Cells[2].CssClass = "Top";
e.Row.Cells[3].CssClass = "Top";
e.Row.Cells[4].CssClass = "Top";
e.Row.Cells[5].CssClass = "RightUpperCorner";
}
if (e.Row.RowIndex == 3 || e.Row.RowIndex == 4 || e.Row.RowIndex == 5)
{
e.Row.Cells[1].CssClass = "Left";
e.Row.Cells[5].CssClass = "Right";
}
if (e.Row.RowIndex == 6)
{
e.Row.Cells[1].CssClass = "LeftLowerCorner";
e.Row.Cells[2].CssClass = "Bottom";
e.Row.Cells[3].CssClass = "Bottom";
e.Row.Cells[4].CssClass = "Bottom";
e.Row.Cells[5].CssClass = "RightLowerCorner";
}
它可能不是最漂亮的,但这并没有真正需要改变,并且总是在同一个位置,所以它符合我的简单需求。