tTable cell and row borders different on each edge in C#
I'm trying to dynamically generate a report in a table where the borders are different on each side of a cell or row, but can't figure out how. The TableRow, TableCell, and Table objects each have a BorderStyle property, but it seems to apply to the entire border rather than just one side. Can this be done without nesting tables?
For my case, I'd like a solid borde开发者_如何学Pythonr around the first two rows of a table (because the first row has a cell spanning two rows), and a solid border around each subsequent row.
This looks like a job for CSS.
The border controls within the ASP.net controls can be chunky and mis-leading to use at best. I would suggest adding some CssStyles to your rows and or cells like this:
TableRow row1 = new TableRow();
row1.CssClass = "rowStyle1";
TableCell cell1 = new TableCell();
cell1.CssClass = "cellStyle1";
And defining up your borders within the CSS tags like this:
rowStyle1 { border-collapse: collapse;
border: 1px solid black; }
etc...
At the very least this will give you a lot more control over the layout of your borders. If you need a good CSS refrence for table borders I would check out the W3.org page here
精彩评论