开发者

Border around a single HtmlRow

开发者 https://www.devze.com 2023-04-05 15:54 出处:网络
I am trying to add a border to just one HtmlRow in C#. The row is going in a table that has a border around it\'s edge. I have tried:

I am trying to add a border to just one HtmlRow in C#. The row is going in a table that has a border around it's edge. I have tried:

row.Attributes.Add("border-bottom", "1px");
row.Attributes.Add("border-color", "#000000");
row.Attributes.Add("border-style", "solid");
row.Style.Add("border-width", "1px");
row.Style.Add("border-color", "#000000");
row.Style.Add("border-style", "solid");
row.BorderColor = "#000000";

resulting html for the row:

<tr class="tableHeader" Style="height:30px;border-width:1px;border-color:#000000;border-style:solid;" border-bottom="1px" border-color="#000000" border-style="solid" bordercolor="#000000">

<tr class="tableHeader" Style="height:30px;border-width:1px;border-color:#000000;border-style:solid;" border-bottom="1px" border-color="#000000" border-style="solid" bordercolor="#000000">
    <td width="25px" align="center"><FONT COLOR=#000000>Last</FONT></td>
    <td width="50px" align="center"><FONT COLOR=#000000>First</FONT></td>
    <td align="center" width="100px"><FONT COLOR=#000000>Address</FONT></td>
    <td width="50px" align="center"><FONT COLOR=#000000>Phone</FONT></td>
</tr>
开发者_Go百科

But none of these have worked. I cannot use a table to make the border because the row is being used to model subsequent rows. Also, if this makes it easier, I only need the bottom of the row to have a border.


you should probably looking to put the style in a style sheet and use a class. it will also make it easier for you to test as you just need to add the style at run time and not each element that create the desired effect.

how about this http://jsfiddle.net/yQbTp/1/

<table id="border">
    <tr>
        <td>apple</td>
        <td>banana</td>
    </tr>
    <tr class="border">
        <td>cherry</td>
        <td>date</td>
    </tr>
    <tr>
        <td>egg</td>
        <td>fruit</td>
    </tr>
    <tr>
        <td>grape</td>
        <td>ham</td>
    </tr>
</table>
table#border{
    width:100%;
    border:1px solid black;
}
table#border tr.border{
    border:1px solid red;
}
table#border tr:last-child{
    border:1px solid green;
}
0

精彩评论

暂无评论...
验证码 换一张
取 消