Visual Studio .NET - Setting one side of a TableCell border at runtime

Asked By C Rule on 21-Mar-06 06:21 PM
I have a Table and am adding TableRows and TableCells dynamically with the bottom border color depending on the data displayed in the cell.
I have not been able to determine how to set just the top border color based on the data.

while (reader.Read())
TableRow r = new TableRow();

TableCell c1 = new TableCell();
c1.Text = reader["columnName"].ToString();
if(entityID != Convert.ToInt32(reader["ColumnID"].ToString()))
c1.BorderColor????? //how do I manipulate just the top part of the border


Thanks for your help.

You need to use style atttributes - Asked By Peter Bromberg on 21-Mar-06 07:44 PM

for this. 

style="margin-top: 2px;" .....

You can create a Css class and then assign the class names:

c1.Attributes.Add("class", "clsMyBorders");

setting a border style on one side of cell in C# - Asked By C Rule on 23-Mar-06 06:57 PM

Thanks for the information - I've obviously not done it correct.
I have included a class in my IPDQA.css file named ".borderTop":


Then in the C# code behind, I've referenced:
c1.Attributes.Add("IPDQA", "borderTop");

But, that didn't work - so I know I've got something messed up in the syntax.

Please let me know what stupid thing I've done wrong.  Thanks.

got it to work thanks - Asked By C Rule on 24-Mar-06 05:49 PM


c1.CssClass = "borderTop";

Thanks for your help.